How to install tsim-0.84 on Windows 10 with Cygwin? - cygwin

For a laboration in class we are using an old train simulator for Linux called tsim. I am trying to get this to run on my Windows 10 laptop with Cygwin but I get an error when running the "make" command.
AddToggleWidget.c:3:27: fatal error: X11/Intrinsic.h: No such file or directory
The thing is I think the simulator is so old that it wants to use this X11/Intrinsic.h from an old library called xorg-x11-devel. Because I already have it in a newer one called libXt-devel. This is based on this old cygwin thread.
I have looked everywhere for a way to get the xorg-x11-devel library but can't find it so any help would be greatly appreciated.
The laboration.
The Train Simulator, tsim(source code).

You need to install the libXt-devel package.
To verify if the libXt-devel is properly installed
$ cygcheck -c libXt-devel
Cygwin Package Information
Package Version Status
libXt-devel 1.1.5-1 OK
As it seems that instead your real problem is how to build tsim on cygwin and you are focusing on the wrong issue, I will also provide you the recipe I used.
The following patch is needed for proper build and link:
--- orig/tsim-0.84/src/Makefile.am 2008-09-10 12:45:17.000000000 +0200
+++ tsim-0.84/src/Makefile.am 2016-09-05 22:06:47.665318000 +0200
## -11,5 +11,6 ##
tsim_CFLAGS = -std=gnu99 -pedantic -Wall -Wextra -Wmissing-prototypes \
-DRESDIR=\"${datadir}/tsim\"
-tsim_LDFLAGS = -L/usr/X11R6/lib -lXaw -lXt -lXmu -lX11 -lXext
+tsim_LDFLAGS = -L/usr/lib
+tsim_LDADD = -largp
--- orig/tsim-0.84/src/bitmap.c 2008-09-08 13:14:16.000000000 +0200
+++ tsim-0.84/src/bitmap.c 2016-09-05 22:14:02.032117400 +0200
## -17,14 +17,14 ##
static void GetBitmapPath(
String name,
String full_name) {
- sprintf(full_name, "%s/%s/%s", app_dir(), bitmap_dir(), name);
+ sprintf(full_name, "%s%s/%s", app_dir(), bitmap_dir(), name);
}
void ReadCustomBitmaps(
Widget w) {
char custom_directory[BUFSIZE];
- sprintf(custom_directory, "%s/%s/customBitmaps", app_dir(), bitmap_dir());
+ sprintf(custom_directory, "%s%s/customBitmaps", app_dir(), bitmap_dir());
gBitmapDirectory = BDAddDirectory(w, custom_directory, NULL);
}
--- orig/tsim-0.84/src/pipe.c 2008-09-09 12:55:58.000000000 +0200
+++ tsim-0.84/src/pipe.c 2016-09-05 18:47:40.261754300 +0200
## -3,6 +3,7 ##
#include <stdlib.h> /* exit */
#include <unistd.h> /* read */
#include <sys/param.h> /* MIN, MAX */
+#include <sys/socket.h>
#if defined sun3 || defined sun4
#include <sys/filio.h>
Makefile.am is changed as /usr/X11R6/lib has been replace long time ago by /usr/lib and the libs should be put in LDADD not on LDFLAGS to avoid problem of order durink linking . -largp is missing from the requirement while the the other libs will be correctly added during configure
The changes in bitmap.c are needed to avoid wrongly loading default data. Cygwin have a dedicate meaning for path starting with "//" that are a side effect of current code.
Step by step instruction:
- install libargp-devel, libX11-devel, libXaw-devel, libXext-devel, libXmu-devel, libXt-devel
- unpack the tsim-0.84.tar.gz
- apply the patch
- run autoreconf , it will properly rebuilds the Makefile.in
- run ./configure it will properly rebuilds the Makefile
- run make
- run make install
- run tsim
As bonus, how the program looks:

Related

How to solve 'Entry Point Not Found' error in a Vulkan project (CMake 3.21/VisualStudio/C++20/VMA/shaderc)

(firstly I'm a chinese, so there might be some syntax errors. I'm sorry for that)
So yesterday I just update my VulkanSDK version to the newest (version 1.3.216.0) as well as VMA, but there's a runtime error occured when I try to run the code which was like : 'Entry Point Not Found'(The picture's chinese)
So I try to clean the Project and Regenerate it but no progress, then I re-installed VulkanSDK and restart my computer but still nothing helped. Later I find that this is a Vulkan error which probably originate from vk_mem_alloc.h (VMA). But I debugged for a few days but still don't understand why "vkGetDeviceImageRequirements" is not find while there seems nothing wrong with "vkGetDeviceBufferMemoryRequirements" which was actually fetched earlier
#if VMA_VULKAN_VERSION >= 1003000
if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 3, 0))
{
VMA_FETCH_DEVICE_FUNC(vkGetDeviceBufferMemoryRequirements, PFN_vkGetDeviceBufferMemoryRequirements, "vkGetDeviceBufferMemoryRequirements");
VMA_FETCH_DEVICE_FUNC(vkGetDeviceImageMemoryRequirements, PFN_vkGetDeviceImageMemoryRequirements, "vkGetDeviceImageMemoryRequirements");
}
#endif
And here is my base.h:
#pragma once
#include <glad/glad.h>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <vulkan/vulkan.hpp>
#include <shaderc/shaderc.hpp>
#include <vma/vk_mem_alloc.h>
This is my CKake list:
cmake_minimum_required(VERSION 3.21)
project(FFEngine_Project)
set(CMAKE_CXX_STANDARD 20)
file(GLOB copyResources "./assets" "./thirdParty/libs/assimp/assimp-vc143-mtd.dll")
file(COPY ${copyResources} DESTINATION ${CMAKE_BINARY_DIR})
include_directories(
SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/thirdParty/include)
include_directories(
SYSTEM D:/Vulkan/VulkanSDK/1.3.216.0/Include)
link_directories(
SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/thirdParty/libs/glfw
SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/thirdParty/libs/assimp
SYSTEM D:/Vulkan/VulkanSDK/1.3.216.0/Lib
)
add_subdirectory(ff)
add_executable(triangle "examples/triangle.cpp")
target_link_libraries(triangle ff_lib glfw3.lib vulkan-1.lib shaderc_sharedd.lib assimp-vc143-mtd.lib)
This error has been confusing me for days, I'm really pissed off... If any more details or codes are needed, ask me, and I'll reply

Register C++ version of Rcpp function and use it within the other Rcpp function in a new package

I have a package hpa that has some functions written in Rcpp. I want to use some of these functions within my new R-package. It is necesseraly to use this functions in "Rcpp form" in order to avoid perfomance penalty so I can't to export them in a usual way.
I have found a similar questions. Following the answer of Dirk Eddelbuettel I have investigated this file and written the following code (within init.c file that has been placed in the src folder) in hope to make polynomialIndex function (from hpa package) become available (in Rcpp i.e. C++ form) for Rcpp functions of other pacakges (including my new one):
#include <Rconfig.h>
#include <Rinternals.h>
#include <R_ext/Rdynload.h>
#include "polynomialIndex.h"
/* definition of functions provided for .Call() */
static const R_CallMethodDef callMethods[] = {
{ "polynomialIndex", (DL_FUNC) &polynomialIndex, 1 },
{ NULL, NULL, 0 }
};
/* functions being called when package is loaded -- used to register */
/* the functions we are exporting here */
void R_init_RApiSerialize(DllInfo *info) {
/* used by external packages linking to internal serialization code from C */
R_RegisterCCallable("hpa", "polynomialIndex",
(DL_FUNC) &polynomialIndex);
R_registerRoutines(info,
NULL, /* slot for .C */
callMethods, /* slot for .Call */
NULL, /* slot for .Fortran */
NULL); /* slot for .External */
R_useDynamicSymbols(info, TRUE); /* controls visibility */
}
Unfortenatelly when I am trying to build hpa package the following error message arise:
/mingw64/bin/gcc -I"C:/R/R-41~1.0/include" -DNDEBUG -I'C:/R/R-4.1.0/library/Rcpp/include' -I'C:/R/R-4.1.0/library/RcppArmadillo/include' -I'C:/R/R-4.1.0/library/RcppParallel/include' -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c init.c -o init.o
In file included from C:/R/R-4.1.0/library/Rcpp/include/Rcpp/r/headers.h:66,
from C:/R/R-4.1.0/library/Rcpp/include/RcppCommon.h:30,
from C:/R/R-4.1.0/library/RcppArmadillo/include/RcppArmadilloForward.h:26,
from C:/R/R-4.1.0/library/RcppArmadillo/include/RcppArmadillo.h:31,
from polynomialIndex.h:4,
from init.c:4:
C:/R/R-4.1.0/library/Rcpp/include/Rcpp/platform/compiler.h:100:10: fatal error: cmath: No such file or directory
#include <cmath>
^~~~~~~
compilation terminated.
make: *** [C:/R/R-41~1.0/etc/x64/Makeconf:238: init.o] Error 1
It seems to be associated with the fact that polynomialIndex.h file includes <RcppArmadillo.h>. The file itself looks as follows:
#ifndef hpa_polynomialIndex_H
#define hpa_polynomialIndex_H
#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace RcppArmadillo;
NumericMatrix polynomialIndex(NumericVector pol_degrees,
bool is_validation);
String printPolynomial(NumericVector pol_degrees,
NumericVector pol_coefficients,
bool is_validation);
#endif
Then I have tried to remove polynomialIndex.h from init.c and to declare polynomialIndex directly inside init.c file. Unfortunatelly it results into the other error message:
/mingw64/bin/gcc -I"C:/R/R-41~1.0/include" -DNDEBUG -I'C:/R/R-4.1.0/library/Rcpp/include' -I'C:/R/R-4.1.0/library/RcppArmadillo/include' -I'C:/R/R-4.1.0/library/RcppParallel/include' -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c init.c -o init.o
** using staged installation
** libs
/mingw64/bin/g++ -std=gnu++11 -shared -s -static-libgcc -o hpa.dll tmp.def ParallelFunctions.o RcppExports.o hpaBinary.o hpaML.o hpaMain.o hpaSelection.o hpaValidation.o init.o normalMoments.o polynomialIndex.o spline.o -LC:/R/R-41~1.0/bin/x64 -lRlapack -LC:/R/R-41~1.0/bin/x64 -lRblas -lgfortran -lm -lquadmath -LC:/R/R-41~1.0/bin/x64 -lR
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: init.o:init.c:(.text+0x8): undefined reference to `polynomialIndex'
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: init.o:init.c:(.rdata+0x28): undefined reference to `polynomialIndex'
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: init.o:init.c:(.rdata$.refptr.polynomialIndex[.refptr.polynomialIndex]+0x0): undefined reference to `polynomialIndex'
Please help me to figure out these problems. In the end I want to be able to use polynomialIndex function within my new package. According to the information I have found it should look something like this (simplifed expample):
// [[Rcpp::depends(hpa)]]
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector newFunc(NumericVector pol_degrees,
bool is_validation) {
static SEXP(*polynomialIndex)(Rcpp::NumericVector, bool) = NULL;
polynomialIndex = (SEXP(*)(Rcpp::NumericVector, bool)) R_GetCCallable("hpa", "polynomialIndex");
NumericVector result = polynomialIndex(pol_degrees, is_validation);
return(result);
}
P.S. This question is also similar to this one but does not resolve my problem.
This has been discussed before, and I would urge you to study these other questions and experiment with their answers.
Here you appear to have a cross-over from a C compilation (started by gcc) touching a file in which you crossed over to C++. Which, plainly stated, you cannot do for C compilation.
R offers C interfaces only. Rcpp helps you by autogenerating complying interface files. If you want to extend/alter them you have to play by the rules.
Wrapping C++ code in (simpler, more portable, cross-compiler, ...) C interfaces is a decades old trick. You likely find many resources for it.
Following Dirk Eddelbuettel's suggestion I have made additional search concerning this problem. Unfortunatelly I have found an extremely simple solution.
First, I have deleted init.c file.
Second, I have added the following line of code to all .cpp files of hpa package.
// [[Rcpp::interfaces(r, cpp)]]
Third I have added the following code to the description file of my new package in order to link it to hpa package (I have made it before the solution has been found but in order to provide a full reciepe it seems reasonable to add this information).
Imports: Rcpp (>= 1.0.6), hpa (>= 1.2.1)
Depends: hpa (>= 1.2.1)
LinkingTo: Rcpp, RcppArmadillo, hpa
Fourth, by the same reasons I have added the following line of code to the namespace file:
import(hpa)
Fifth, I have compiled hpa package (as usual) and have found a new folder named inst. Inside this folder there is a folder include. In this folder I have found a new file hpa.h. So I have simply included this file into the code and simplified the call to the function to hpa::polynomialIndex(...). So the resulting (succesfully working!) code is as follows:
// [[Rcpp::depends(hpa)]]
#include <RcppArmadillo.h>
#include <hpa.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector newFunc(NumericVector pol_degrees,
bool is_validation) {
NumericVector result = hpa::polynomialIndex(pol_degrees, is_validation);
return(result);
}
P. S. It was informative to investigate the file hpa\inst\include\hpa_RcppExports.h to understand how does [[Rcpp::interfaces(r, cpp)]] resolves the problem.

Error: conflicting types when trying to make a simple syscall

I'm brand new to Linux programming and I'm trying to implement a simple system call loosely following this guide: https://medium.com/anubhav-shrimal/adding-a-hello-world-system-call-to-linux-kernel-dad32875872. In my linux kernel directory, I created a new directory called my_syscall. Within that directory, I created my_syscall.c. Here is my_syscall.c
#include <linux/syscalls.h>
#include <linux/kernel.h>
asmlinkage long sys_my_syscall(int i) {
prink(KERN_INFO "This is the system call.");
return(0);
}
I then created a Makefile in the my_syscall directory with a single line:
obj-y := my_syscall.o
I then edited this line in the Makefile in the kernel directory to be:
core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ my_syscall/
Then, in the directory linux-5.4.15/arch/x86/entry/syscalls, I edited the syscall_64.tbl to include the following line at the very end:
548 64 my_syscall sys_my_syscall
Finally, in the directory linux-5.4.15/include/linux, I edited the syscalls.h file to include this line before the #endif:
asmlinkage long sys_my_syscall(int i);
Now, when I run the command sudo make, I run into the following error soon after:
./arch/x86/include/generated/asm/syscalls_64.h:2664:19: error: conflicting types for 'sys_my_syscall'
__SYSCALL_64(548, sys_my_syscall, )
arch/x86/entry/syscall_64.c:18:60: note: in definition of macro '__SYSCALL-64'
#define __SYSCALL_64(nr, sym, qual) extern asmlinkage long sym(const struct pt_regs *);
In file included from arch/x86/entry/syscall_64.c:7:0:
./include/linux/syscalls.h:1423:17: note: previous declaration of 'sys_my_syscall' was here
asmlinkage long sys_my_syscall(int i);
^
make[3]: *** [arch/x86/entry/syscall_64.o] Error 1
make[2]: *** [arch/x86/entry] Error 2
make[1]: *** [arch/x86] Error 2
make: *** [sub-make] Error 2
I have no idea how to approach this error. With a conflicting types error, I would think I declared the syscall differently in someplace, but in both my_syscall.c and the syscalls.h files, the declaration is the same. These were the only two files where the syscall is declared, but it is also named within syscall_64.tbl and it seems like this is where linux is trying to point me towards. However, I don't see what's wrong with how I declared it in the table as I followed the guide directly. Any help with this would be greatly appreciated!
Info:
Kernel version: 5.4.15
Linux Distribution: Ubuntu 14
I just changed the location where the syscall number is defined in syscall_64.tbl.
Instead of this:
548 64 my_syscall sys_my_syscall
I wrote this:
436 common my_syscall __x64_sys_my_syscall
Screen Capture of my configuration
It worked out.
I'm doing something similar and got the exact same error.
What fixed the error for me is changing the last part of the syscall_64.tbl table entry from "sys_my_syscall" to "__x64_sys_my_syscall". If you scroll up, other entries have the same prefix. The kernel started compiling after I made that change.
I eventually gave up on trying to implement this in kernel 5. Unfortunately, none of the other solutions resulted in my kernel compiling. I rolled back my kernel and followed the steps here. This resulted in the system call working correctly. I'm not sure how to make this function in kernel 5+.
#include <linux/syscalls.h>
#include <linux/kernel.h>
SYSCALL_DEFINE1(my_syscall, int, i)
{
printk(KERN_INFO "This is the system call (param %d).\n", i);
return(0);
}
For kernel 5, try deleting "sys_" before "my_syscall" and try. It worked for me
Some architectures (including x86-64) use syscall wrappers to call the real syscall handler. To define the real syscall handler and its wrappers (for architectures that use syscall wrappers), use one of the SYSCALL_DEFINE<n> macros before the body of the syscall handler. The parameters of the SYSCALL_DEFINE<n> macros are the function name, followed by <n> pairs of ``type, param'' for the function parameters.
Your sys_my_syscall syscall handler function has one parameter, so use the SYSCALL_DEFINE1 macro before the body of the function:
#include <linux/syscalls.h>
#include <linux/kernel.h>
SYSCALL_DEFINE1(sys_my_syscall, int, i)
{
printk(KERN_INFO "This is the system call (param %d).\n", i);
return(0);
}

Unable to add a custom system call on x86 ubuntu linux

I am new to this and just learning about the kernel, and I am trying to add a custom call to kernel 4.20.4. This is the steps that I did.
First I create the file (kernel/printmsg.c) that contains the code.
#include <linux/kernel.h>
#include <linux/syscalls.h>
SYSCALL_DEFINE1(printmsg, int, i)
{
printk(KERN_DEBUG, "TESTING %d", i);
return 1;
}
Next, I add this file to the kernel/Makefile
obj-y = fork.o exec_domain.o panic.o \
// A few more lines
obj-y += printmsg.o // I added this line
Finally, I add the system call to the syscall table on arch/x86/entry/syscalls/syscall_64.tbl(I'm building this on a 64-bit Ubuntu) by appending this line:
548 64 printmsg sys_printmsg
Now, I proceed to run make. However, it has this error:
arch/x86/entry/syscall_64.o:(.rodata+0x1120): undefined reference to `sys_printmsg'
Makefile:1034: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1
I've been scratching my head for a long time for this but I can't seem to realised what went wrong.
Hope that anyone that managed to find a problem can help out a poor soul. Thanks in advance!
Okay, after hours of trial and error, I have finally found the problem. From linux kernel v4.17 onwards, x86_64 system calls may begin with "__x64_sys".
So, instead of using 548 64 printmsg sys_printmsg, I changed it to 548 64 printmsg __x64_sys_printmsg. Then everything works.
Hoped this helped everyone that might have this problem.

Update variables within makefile label

I have C++ static libraries and executable that uses them, each one is in a seperate folder. Each such project can be built in Debug or Release configuration, when the files hierarchy is like the following:
Static_Lib1\Debug\staticlib1.a
Static_Lib1\Release\staticlib1.a
//same for all other static libraries
Executable\Debug\executable
Executable\Release\executable
All Debug and Release folders contain makefiles.
I'm trying to write an external makefile to call each one of the internal projects, using the selected configuration - debug or release.
So, I tried something like:
CFG= #empty declaration
PROJECTS=Static_Lib1 Static_Lib2 ... Executable
all:
release #default config is release
release:
CFG = Release
make build-all
debug:
CFG = Debug
make build-all
build-all:
make clean
$(foreach projectName, $(PROJECTS), cd $(projectName)/$(CFG) && make all;)
But I get this output when trying, for example, to run make debug:
CFG = Debug
make: CFG: Command not found
make: *** [debug] Error 127
How can I fix this?
My OS is SLED 11x64.
Thank you in advance!
Change it to:
...
release:
make CFG=Release build-all
debug:
make CFG=Debug build-all
...

Resources