Problem
If I try to compile c-code (from a FMU exported by JModelica) with emcc, I get an error that the header file "gnu/stubs-32.h" was not found.
emcc -I /usr/include/ -I /usr/include/x86_64-linux-gnu/ -I /usr/include/x86_64-linux-gnu/bits/ -I /home/osboxes/Programme/JModelica/include/RuntimeLibrary/ -I /home/osboxes/Programme/JModelica/ThirdParty/FMI/2.0/ BouncingBall.c
Error
/usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11 fatal error: 'gnu/stubs-32.h' file not found
I already tried to provide the compiler with the required header files by installing libc6-dev:i386 . But it will not work because compiling 32-bit software on a 64-bit machine. The guys from emscripten already told me, that there is no working 32-bit version of the emcc compiler available. So I think the only way is to go on with 64-bit...
I found in gnu/stubs.h the file which is responsible for the selection of the wrong header file:
#if !defined __x86_64__
# include <gnu/stubs-32.h>
#endif
#if defined __x86_64__ && defined __LP64__
# include <gnu/stubs-64.h>
#endif
#if defined __x86_64__ && defined __ILP32__
# include <gnu/stubs-x32.h>
#endif
Therefore I conclude that __LP64__
is not defined but should be defined to be able to use the 64-bit header files.
Does anyone has in idea how I am able to compile the c-code with emcc?
Addition (added 16.08.2019)
I started another try:
Compiling without system headers emcc -I /home/osboxes/Programme/JModelica/include/RuntimeLibrary/ -I /home/osboxes/Programme/JModelica/ThirdParty/FMI/2.0/ BouncingBall.c
results in this error 'linux/limits.h' file not found
.
So I visited the file where 'linux/limits.h' gets included. It is a header file of JModelica with name /../JModelica/include/RuntimeLibrary/jmi_utils.h
:
...
#if !defined(NO_FILE_SYSTEM) && (defined(RT) || defined(NRT))
#define NO_FILE_SYSTEM
#endif
#ifndef NO_FILE_SYSTEM
#ifdef _WIN32
#include <windows.h>
#define JMI_PATH_MAX MAX_PATH
#else
#define _GNU_SOURCE
#include <dlfcn.h>
#ifdef __APPLE__
#include <limits.h>
#define JMI_PATH_MAX PATH_MAX
#else
#include <linux/limits.h>
#define JMI_PATH_MAX PATH_MAX
#endif
#endif
#include <sys/types.h>
#include <sys/stat.h>
#endif
...
So I defined 'RT' by passing emcc -I /home/osboxes/Programme/JModelica/include/RuntimeLibrary/ -I /home/osboxes/Programme/JModelica/ThirdParty/FMI/2.0/ BouncingBall.c -DRT
to the emcc compiler and everything worked without errors.
But what are the variables RT and NRT? Do I have to worry about something by doing that?
My environment:
- Ubuntu 18.10 (64-bit)
- JModelica (version r12614)
- Emscripten (emcc: 1.3820 / clang: 6.0.1 / Target: x86_64-unknown-linux-gnu / selected gcc: /usr/lib/gcc/x86_64-linux-gnu/8)