ghorwin / FMICodeGenerator

A Code Generator that creates native C/C++ code to build Functional Mock-Up Units (FMU) with support for FMI version 2.0 (rollback)
BSD 3-Clause "New" or "Revised" License
51 stars 25 forks source link

FMU in Eclipse with MinGW Compiler #39

Closed GreroDe closed 2 years ago

GreroDe commented 2 years ago

Hi everyone!

I am new in the area and I was interacting a little bit the source code using Eclipse IDE to generate FMUs. The exported DLL file works fine when I am using Microsoft Visual C++ compiler, but when I switched to MinGW compiler the .dll file does not work. I was checking the exported DLL file with Dependency Walker and I saw that the file has problems with Kernell32.dll and MSVCRT.dll. Is there any reason why it can't work with the MinGW compiler and if possible, what should I do to link the necessary libraries with the code to generate the DLL file?

Thank you all for the help.

ghorwin commented 2 years ago

Hi, generally, the application loading the FMU-DLL needs to find all referenced libraries (also those referenced by the DLL itself). So if you compiled the FMU with Visual Studio, then you need to place the VC runtime libraries into the exe-directory or adjust your PATH variable accordingly.

If you compile the FMU with MinGW, the resulting FMU-DLL should no longer reference the VC runtimes, but rather the GCC/MingW runtime DLLs. Similarly, these need to be present to the application loading the DLL.

GreroDe commented 2 years ago

Thanks @ghorwin for the information. I already added the MinGW path in the environment variables, generated the dll file and added it to the .fmu file. It still doesn't work. I wanted to try adding the runtime libraries in the exe directory. Do you know what the libraries are or maybe if you can give me a tip on how to do it. Thanks in advance.

ghorwin commented 2 years ago

All missing DLLs must be located and be in the PATH in the correct versions. This is not an FMUCodeGenerator issue, but rather a general Windows dll locator problem. Maybe your PATH variable contains directories with other runtime libs of different versions? Otherwise, please post the error messages you get!

GreroDe commented 2 years ago

Thank you It works.