Modelica_DeviceDrivers is not compatible with imported Co-Simulation FMUs in Dymola
Closed this issue · 2 comments
A model with both Modelica_DeviceDrivers and FMU does not compile due to multiple definitions of several Winsock data types.
In the windows kit its clearly mentioned that "#error Do not include winsock.h and ws2def.h in the same module. Instead include only winsock2.h."
Modelica_DeviceDrivers is using windows.h and all the FMUs include a header file that includes windows.h which includes winsock.h. So there is a conflict.
please find the attached log.
dslog.txt
Ah, I can reproduce now. The missing piece of information was, that the FMU must be a CS FMU since the compilation error does not occur for ME FMUs.
This is an issue of the Dymola 2021 FMI sources. My recommended workaround (for you to continue) is to replace
#include "windows.h"
by
#if !defined(WIN32_LEAN_AND_MEAN)
#define WIN32_LEAN_AND_MEAN
#endif
#include "windows.h"
in both E:\Dymola2021_Installation\Source\FMI\fmiImport.h and E:\Dymola2021_Installation\Source\FMI\fmi2Import.h
@d94pn @HansOlsson FYI
@beutlich thanks for the analysis
Fixed for Dymola 2022
If you need for previous version you can find the headers in your "dymola install dirctory" \Source\FMI
backup your files fmiImport.h and fmi2Import.h
Then apply the fix recommended by @beutlich
Alternatively contact Dymola support and we can provide a fix for you.