FMIKit-Simulink
FMIKit-Simulink copied to clipboard
Can't generate FMU file.
I have created a simulink model and configured the
System target file:
to rtwsfcnfmi.tlc
and FMI type
to ModelExchange
, but I can't generate the FMU file. Here is the error code :
### Generating code and artifacts to 'Model specific' folder structure
Code Generation 1
Elapsed: 3 sec
### Generating code into build folder: /home/zpl/src/modelica/Dymola/untitled_sfcn_rtw_fmi
### Invoking Target Language Compiler on untitled.rtw
### Using System Target File: /home/zpl/src/modelica/Dymola/FMIKit-Simulink/rtwsfcnfmi/rtwsfcnfmi.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
.
### Caching model source code
### Writing header file untitled_sf_types.h
### Writing header file untitled_sf.h
.
### Writing header file rtwtypes.h
### Writing header file multiword_types.h
### Writing source file untitled_sf.c
### Writing header file untitled_sf_private.h
### Writing header file untitled_sid.h
### Writing header file untitled_mid.h
### Writing source file untitled_sf_data.c
.
### Writing header file rtGetNaN.h
### Writing source file rtGetNaN.c
### Writing header file rt_nonfinite.h
### Writing source file rt_nonfinite.c
### Writing header file rt_defines.h
### Writing header file rtGetInf.h
.
### Writing source file rtGetInf.c
### TLC code generation complete.
### Writing modelDescription.xml
### Generating project
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
FIPXT_SHARED_MODULE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zpl/src/modelica/Dymola/untitled_sfcn_rtw_fmi
### Building FMU
Scanning dependencies of target untitled
[ 9%] Building C object CMakeFiles/untitled.dir/fmi2Functions.c.o
/home/zpl/src/modelica/Dymola/FMIKit-Simulink/rtwsfcnfmi/fmi2Functions.c: In function ‘fmi2Instantiate’:
/home/zpl/src/modelica/Dymola/FMIKit-Simulink/rtwsfcnfmi/fmi2Functions.c:130:48: warning: passing argument 2 of ‘InstantiateModel’ from incompatible pointer type [-Wincompatible-pointer-types]
model = InstantiateModel(instanceName, logMessage, fmuType == fmi2CoSimulation, callbacks);
^~~~~~~~~~
In file included from /home/zpl/src/modelica/Dymola/FMIKit-Simulink/rtwsfcnfmi/fmi2Functions.c:20:0:
/home/zpl/src/modelica/Dymola/FMIKit-Simulink/rtwsfcnfmi/sfunction.h:70:8: note: expected ‘logMessageCallback {aka void (*)(struct Model_s *, enum <anonymous>, const char *)}’ but argument is of type ‘void (*)(Model *, int, const char *) {aka void (*)(struct Model_s *, int, const char *)}’
Model *InstantiateModel(const char* instanceName, logMessageCallback logMessage, int isCoSim, void *userData);
^~~~~~~~~~~~~~~~
/home/zpl/src/modelica/Dymola/FMIKit-Simulink/rtwsfcnfmi/fmi2Functions.c: In function ‘fmi2Reset’:
/home/zpl/src/modelica/Dymola/FMIKit-Simulink/rtwsfcnfmi/fmi2Functions.c:274:59: warning: passing argument 2 of ‘InstantiateModel’ from incompatible pointer type [-Wincompatible-pointer-types]
InstantiateModel(model->instanceName, logMessage, model->isCoSim, model->userData);
^~~~~~~~~~
In file included from /home/zpl/src/modelica/Dymola/FMIKit-Simulink/rtwsfcnfmi/fmi2Functions.c:20:0:
/home/zpl/src/modelica/Dymola/FMIKit-Simulink/rtwsfcnfmi/sfunction.h:70:8: note: expected ‘logMessageCallback {aka void (*)(struct Model_s *, enum <anonymous>, const char *)}’ but argument is of type ‘void (*)(Model *, int, const char *) {aka void (*)(struct Model_s *, int, const char *)}’
Model *InstantiateModel(const char* instanceName, logMessageCallback logMessage, int isCoSim, void *userData);
^~~~~~~~~~~~~~~~
[ 18%] Building C object CMakeFiles/untitled.dir/sfunction.c.o
/home/zpl/src/modelica/Dymola/FMIKit-Simulink/rtwsfcnfmi/sfunction.c: In function ‘SetInputPortDimensionInfoFcn_FMI’:
/home/zpl/src/modelica/Dymola/FMIKit-Simulink/rtwsfcnfmi/sfunction.c:146:26: error: lvalue required as left operand of assignment
((char *)inputSignals) += typeSize;
^~
CMakeFiles/untitled.dir/build.make:86: recipe for target 'CMakeFiles/untitled.dir/sfunction.c.o' failed
make[2]: *** [CMakeFiles/untitled.dir/sfunction.c.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/untitled.dir/all' failed
make[1]: *** [CMakeFiles/untitled.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
The call to rtwsfcnfmi_make_rtw_hook, during the after_make hook generated the following error:
Failed to build FMU
The build process will terminate as a result.
Caused by:
Failed to build FMU
Component:Simulink | Category:Block diagram error
Maybe this error is caused by the new version that I built. I will try using the release version 2.6 to test again.
Maybe this error is caused by the new version that I built. I will try using the release version 2.6 to test again.
I get a new error.
Unable to locate template makefile: rtwsfcnfmi_18b_Unix.tmf
And I try to build the Fmikit v2.7, I get a same error
I think the main error is lvalue required as left operand of assignment
My matlab is 2018b and the GCC is 7.5.0 and the system is ubuntu 18.04
I use the release version in my windows system, It has no error, but When I use it is Ubuntu system, It has a lvalue required as left operand of assignment
error even if I have compiled the GCC version to 6.3.0.
Does the problem still exist with v3.0-alpha.1?
I think the main error is
lvalue required as left operand of assignment
I had the same problem and I suggested a fix to this in #305
If you change https://github.com/CATIA-Systems/FMIKit-Simulink/blob/87cacf72a030650d042fb99b2d9fbfb17eec3a01/rtwsfcnfmi/sfunction.c#L146 to
inputSignals = ((char *) inputSignals) + typeSize;
the problem is apparently solved.
However, even after fixing this issue, I am not able to use the FMU. Further infos in #305