Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#5227 closed defect (fixed)

TableTest not working under Win32 again

Reported by: Rüdiger Franke Owned by: Martin Sjölund
Priority: blocker Milestone: 1.13.0
Component: Build Environment Version:
Keywords: Cc: Niklas Worschech

Description (last modified by Rüdiger Franke)

This issue had been solved 9 months ago in #4772 and re-appears in a different form now. The example is:

model TableTest
  extends Modelica.Blocks.Tables.CombiTable2D(
      table = [0.0,   1.0,   2.0,   3.0;
               1.0,   1.0,   3.0,   5.0;
               2.0,   2.0,   4.0,   6.0]);
  annotation(uses(Modelica(version="3.2.2")));
end TableTest;

FMI export from OMEdit under Win32 raises now (Cpp runtime selected):

g++ -shared -o TableTest.dll OMCppTableTestCalcHelperMain.o -L"C:/OpenModelica1.13.0-dev-32bit//lib//omc/cpp"  -Wl,--no-undefined -lOMCppSystem_static -lOMCppMath_static -lOMCppModelicaUtilities_static -lOMCppFMU_static -lOMCppNewton_static -lOMCppDgesvSolver_static -lOMCppExtensionUtilities_static -L"C:/someworkdir" "-LC:/OpenModelica1.13.0-dev-32bit//lib//omc" "-LC:/OpenModelica1.13.0-dev-32bit//lib/" "-L%APPDATA%/.openmodelica/binaries/TableTest" "-LC:/someworkdir/Resources/Library/mingw32" "-LC:/someworkdir/Resources/Library/win32" "-LC:/someworkdir/Resources/Library" -lModelicaStandardTables -lModelicaIO -lModelicaMatIO -lzlib "-L%APPDATA%/.openmodelica/binaries/Modelica" "-LC:/OpenModelica1.13.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/Resources/Library/mingw32" "-LC:/OpenModelica1.13.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/Resources/Library/win32" "-LC:/OpenModelica1.13.0-dev-32bit/lib/omlibrary/Modelica 3.2.2/Resources/Library" -lOMCppModelicaUtilities_static  -lOMCppDgesv_static -static 
C:/OpenModelica1.13.0-dev-32bit//lib//omc\libModelicaMatIO.a(ModelicaMatIO.o): In function `Mat_class_type_to_hid_t': 
C:\dev\e\OM32bit\OMCompiler\3rdParty\ModelicaExternalC\BuildProjects\autotools/../../C-Sources/ModelicaMatIO.c:18387: undefined reference to `H5open' 
C:\dev\e\OM32bit\OMCompiler\3rdParty\ModelicaExternalC\BuildProjects\autotools/../../C-Sources/ModelicaMatIO.c:18387: undefined reference to `H5T_NATIVE_LLONG_g' 
...

Attempting to manually add -lz -lhdf5 (as done for the simulator), yet another linker error comes up:

g++ -shared -o TableTest.dll OMCppTableTestCalcHelperMain.o -L"C:/OpenModelica1.13.0-dev-32bit//lib//omc/cpp"  -Wl,--no-undefined -lOMCppSystem_static -lOMCppMath_static -lOMCppModelicaUtilities_static -lOMCppFMU_static -lOMCppNewton_static -lOMCppDgesvSolver_static -lOMCppExtensionUtilities_static -L"C:/someworkdir" "-LC:/OpenModelica1.13.0-dev-32bit//lib//omc" "-LC:/OpenModelica1.13.0-dev-32bit//lib/" "-L%APPDATA%/.openmodelica/binaries/TableTest" "-LC:/someworkdir/Resources/Library/mingw32" "-LC:/someworkdir/Resources/Library/win32" "-LC:/someworkdir/Resources/Library" -lModelicaStandardTables -lModelicaIO -lModelicaMatIO -lzlib -lhdf5 -lz "-L%APPDATA%/.openmodelica/binaries/Modelica" "-LC:/OpenModelica1.13.0-dev-32bit/lib/omlibrary/Modelica3.2.2/Resources/Library/mingw32" "-LC:/OpenModelica1.13.0-dev-32bit/lib/omlibrary/Modelica3.2.2/Resources/Library/win32" "-LC:/OpenModelica1.13.0-dev-32bit/lib/omlibrary/Modelica3.2.2/Resources/Library" -lOMCppModelicaUtilities_static  -lOMCppDgesv_static -static
C:/OpenModelica1.13.0-dev-32bit/tools/msys/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../lib\libhdf5.a(H5Z.c.obj):(.text+0x6e4): undefined reference to `SZ_encoder_enabled'
C:/OpenModelica1.13.0-dev-32bit/tools/msys/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../lib\libhdf5.a(H5Zszip.c.obj):(.text+0xee): undefined reference to `SZ_BufftoBuffDecompress'
C:/OpenModelica1.13.0-dev-32bit/tools/msys/mingw32/bin/../lib/gcc/i686w64-mingw32/5.3.0/../../../../lib\libhdf5.a(H5Zszip.c.obj):(.text+0x1a7): undefinedreference to `SZ_BufftoBuffCompress'
collect2.exe: error: ld returned 1 exit status
TableTest_FMU.makefile:93: recipe for target 'TableTest.fmu' failed
make: *** [TableTest.fmu] Error 1

The additional link dependency to -lsz cannot be fulfilled (a misconfiguration of the static libhdf5.a?).

It is generally redigulous to have that many link dependencies for such a simple Modelica model.

Change History (15)

comment:1 by Adrian Pop, 6 years ago

The linking should be with: -lhdf5 -lz -lszip

comment:3 by Rüdiger Franke, 6 years ago

What about -lzlib that is linked so far? Should it be replaced? Is there a difference between Windows and Linux?

comment:4 by Adrian Pop, 6 years ago

We don't link with -lzlib on Windows / mingw. For mingw we have hardcoded lib flags in omc_config.h as the environment does not change.

I don't really know how it is on Linux. I think that configure for the MSL sources finds the needed flags, but I'm not sure.

comment:5 by Martin Sjölund, 6 years ago

For Linux it's a shared library, so no additional flags are needed

comment:6 by Rüdiger Franke, 6 years ago

Description: modified (diff)

comment:7 by Rüdiger Franke, 6 years ago

For Linux we link Cpp FMUs statically as well to improve portability. SimCode.makefileParams.libs contains -lModelicaStandardTables -lModelicaIO -lModelicaMatIO -lzlib, besides more. This is independent of the platform, but obviously wrong under Windows.

comment:8 by Martin Sjölund, 6 years ago

The problem with statically linked FMUs for us is that for example lapack depends on libgfortran, which cannot be statically linked into a shared object (not compiled with -fPIC).

comment:9 by Rüdiger Franke, 6 years ago

Yes, we rather reduce features, e.g. no libgfortran, in favor of portability. But it's constant work against attempts to just link in all kind of libraries, like hdf5, because they happen to lie around on the development machine and someone might need it somewhen. I opened a ticket for MSL and need to work hard to not get muted immediately by MSL officers.

Where does SimCode.makefileParams.libs come from -- hardly from the include linked by Adrian above??

comment:11 by Rüdiger Franke, 6 years ago

The best solution might be to re-add own ModelicaExternalC libraries to the Cpp runtime, compiled without HDF5. These link dependencies are not specified in MSL; tables only state:

  annotation (Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});

Increadible that MSL maintainers who care about each character don't mind such a dependency mess.

comment:12 by Rüdiger Franke, 6 years ago

Description: modified (diff)

comment:13 by Rüdiger Franke, 6 years ago

Commit https://github.com/OpenModelica/OMCompiler/commit/210af859fbe9b87504c7aaf4048f00215e0cc709 re-adds external libs locally to the Cpp runtime, using default features (no additional compiler flags).

Hopefully this will work out under Windows.

comment:14 by Adrian Pop, 6 years ago

Resolution: fixed
Status: newclosed

Tested on 64bit windows:

adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/bugs/5227
$ time ~/dev/OpenModelica/build/bin/omc +simCodeTarget=Cpp t.mos
true
""
true
""
"C:/home/adrpo33/dev/OMTesting/bugs/5227/TableTest.fmu"
""

in reply to:  11 comment:15 by Francesco Casella, 6 years ago

Replying to rfranke:

The best solution might be to re-add own ModelicaExternalC libraries to the Cpp runtime, compiled without HDF5. These link dependencies are not specified in MSL; tables only state:

  annotation (Library={"ModelicaStandardTables", "ModelicaIO", "ModelicaMatIO", "zlib"});

@rfranke, would you mind opening a pull request to fix this issue on MSL?

Note: See TracTickets for help on using tickets.