modelon-community / fmi-library

C library for importing FMUs
Other
115 stars 34 forks source link

issue with methods jm_log* #15

Open nameabs opened 3 years ago

nameabs commented 3 years ago

Hello,

I started a project based on the cmake fmi-library, i made a few ajustment for my own project but the project works fine on eclipse with the "cmake4eclipse" module. My need is to compile the project outside the cmake context, i'd like to integrate this code on a C++ project non cmake based(Mingw64 compiler). After some time of ajustment and troubeshooting, i'm stuck with an issue of the type ("undefined reference to") while linking the project. It seems that the definitions of methods jmlog* is not in the project but rather contained in a dll (here i found the definitions in a OpenModelica dll since i use FMU from OpenModelica).

My question is : is it possible to access the source code of jm_log functions or where can i find a 64 bits library containing the definitions ? I already tried the OpenModelica dll(s) but it seems that those libs are in 32 bits (my compiler return "skipping incompatible" while trying to add them in the project as library, i'm confident it's not eclipse setting issue based).

I thank you in advance

filip-stenstrom commented 3 years ago

mingw64: FMI Library is tested and built with mingw64 (TDM-GCC). Config is given in build/config/mingw_w64. Maybe this is of some help.

jmlog* functions are defined here: src/Util/src/JM/jm_callbacks.c (by calling macro CREATE_LOG_FUNCTIONS).

nameabs commented 3 years ago

Hello again,

Thank you for your answear, The config file suggest the option -m64, adding this to the compiler flag make it work. To summarize, in order to find the definition of jm_log functions i had to add the dll libfmi_shared and add also the option -m64 to my c++ project. Now, i have issues with jm_vector, the thing is that i can't find any dll containing the definition of those vector(fmilib contains however the jm_log definitions but not the vector ones). And so i find myself with undefined reference while linking... Using Cmake make it work but i can't pinpoint what's making it work on cmake and not on mingw64...

Any more suggestion ?

Thank you.

filip-stenstrom commented 3 years ago

jmvector* function definitions etc. should be created from jm_templates_inst.c at least for the primitive types. I the template is used on a few more places, all of which will create definitions for jm_vector.

If you just compile all .c files and link them I don't know why you don't get the definitions.

nameabs commented 3 years ago

Hello,

After investigation, my issue is located with the template in the file jm_vector.h (jm_vector_declare_template(int,double,etc..) line 359. From what i can understand, the jm_vector_declare_template, instantiate the templates from char through jm_name_ID_map_t.

While linking, the issue start on the second call of declare template, meaning i'm able to link the char template but not the others types that follow.. the linking error is the following : undefined reference to 'jm_vector_copy_int'.

Thank you