Hopsan / hopsan

Hopsan is a free multi-domain system simulation tool developed at the division of Fluid and mechatronic systems at Linköping university.
Apache License 2.0
157 stars 43 forks source link

Issue when exporting to FMU #2211

Closed ishengyeh closed 5 months ago

ishengyeh commented 5 months ago

Hi, First of all, many thanks for such a great software. I am experiencing trouble exporting a Hopsan hmf file to FMU, e.g., FMU 2 when updating to the latest release of Hopsan 2.21.1, It works fine till Hopsan 2.20. Here are attached the zipped hmf file and the error message. Your help will be highly appreciated. Best Isheng --------- hmf file -------- case23_hopsan.zip -------- error message ------- Loaded hopsangenerator Copying HopsanCore source, header and dependencies... Copying C:/Program Files/Hopsan/HopsanCore Copying default component library... Copying C:/Program Files/Hopsan/componentLibraries/defaultLibrary Generating C:/Users/iyeh/FMU/FMU_Manager_5.2_031724/dyna_key/case23_inv_pend_hopsan/fmu-build/fmu2_model.c Generating C:/Users/iyeh/FMU/FMU_Manager_5.2_031724/dyna_key/case23_inv_pend_hopsan/fmu-build/model.hpp Replacing namespace

Compiling FMU source code

Generating Makefile Generating compilation script Calling compilation script g++ -c -std=c++14 -DHOPSAN_INTERNALDEFAULTCOMPONENTS -DHOPSAN_INTERNAL_EXTRACOMPONENTS -DHOPSANCORE_NOMULTITHREADING -I"HopsanCore/include" -I"componentLibraries/defaultLibrary" -I"HopsanCore/dependencies/rapidxml" -I"HopsanCore/dependencies/indexingcsvparser/include" -I"HopsanCore/dependencies/libnumhop/include" -I"HopsanCore/dependencies/sundials-extra/include" -I"HopsanCore/dependencies/sundials/include" -IC:/Program Files/Hopsan/dependencies/fmi4c/include -c fmu2_model.c -o fmu2_model.o g++ -c -std=c++14 -DHOPSAN_INTERNALDEFAULTCOMPONENTS -DHOPSAN_INTERNAL_EXTRACOMPONENTS -DHOPSANCORE_NOMULTITHREADING -I"HopsanCore/include" -I"componentLibraries/defaultLibrary" -I"HopsanCore/dependencies/rapidxml" -I"HopsanCore/dependencies/indexingcsvparser/include" -I"HopsanCore/dependencies/libnumhop/include" -I"HopsanCore/dependencies/sundials-extra/include" -I"HopsanCore/dependencies/sundials/include" -IC:/Program Files/Hopsan/dependencies/fmi4c/include -c HopsanCore/src/Component.cpp -o Component.o Makefile:21: recipe for target 'fmu2_model.o' failed Makefile:18: recipe for target 'Component.o' failed

g++: error: Files/Hopsan/dependencies/fmi4c/include: No such file or directory bin\mingw32-make.exe: [fmu2_model.o] Error 1 bin\mingw32-make.exe: Waiting for unfinished jobs.... g++: error: Files/Hopsan/dependencies/fmi4c/include: No such file or directory bin\mingw32-make.exe: *** [Component.o] Error 1

File 'C:/Users/iyeh/FMU/FMU_Manager_5.2_031724/dyna_key/case23_inv_pend_hopsan/fmu-stage/binaries/win64/case23_hopsan.dll' not found in directory ''

robbr48 commented 5 months ago

This is already fixed by #2202 and will work in the next release, which is expected quite soon.

You may also fix it yourself by editing the Makefile and addint quotation marks around the path to fmi4c. It is located in the "fmu-build" directory in the export folder. Then call "compile.ps1". If everything works you can then manually zip the contents of the fmu-stage folder and rename the file to extention ".fmu".

ishengyeh commented 5 months ago

@robbr48 : thank you so much, highly appreciate it.

ishengyeh commented 5 months ago

@robbr48 : I failed to locate this file: HopsanGenerator/src/generators/HopsanFMIGenerator.cpp in "program files/hopsan" and make the change as suggested in #2202 . Could you please let m w know where exactly it is? Thanks.

ishengyeh commented 5 months ago

@robbr48 , please ignore my last question. I know what you mean now. Thanks.