CATIA-Systems / FMIKit-Simulink

Import and export Functional Mock-up Units with Simulink
Other
157 stars 51 forks source link

FMU import block failed with “User source code” checked #359

Open suijiacai2016 opened 2 years ago

suijiacai2016 commented 2 years ago

i test both release 2.9 and release 3.0, both are errors like below. Compiling S-function sfun_test_FMU2 Building with 'Microsoft Visual C++ 2017 (C)'. Failed to compile S-function sfun_test_FMU2.c \simstruc_compcond.h(316): fatal error C1189: #error: Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE

the FMU archive is generated by grtfmi.tlc with sources included. and the model is simple : just times the input by two. after load the FMU archive, it is ok when not check "User source code".

t-sommer commented 2 years ago

Please provide steps to reproduce the problem

suijiacai2016 commented 2 years ago

1, build a simulink model with grtfmi.tlc, which configuration setting are FMI2, CMake, MinGW makefiles, include source code 2, create a new simulink model with grtfmi.tlc , the configuration setting is the same as first step. Then drag the FMU import block to it. load the FMU arhive generated by the first step. 3, as default setting, the new simulink model is able to run and generated code normally. 4, if i checked the "User source code" at the advanced page of FMU block, error says : Compiling S-function sfun_test_FMU2 Building with 'Microsoft Visual C++ 2017 (C)'. Failed to compile S-function sfun_test_FMU2.c \simstruc_compcond.h(316): fatal error C1189: #error: Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE. 4, i also try the Microsoft Visual C++ 2017 (C) other than the MinGW makefile for both models, the error message is the same as before. when you click on apply button or click on ok button on FMU import block, it is #error: Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE. PS: the simulink version is RL2019a, mex -setup is Microsoft Visual C++ 2017 (C)