-static-libstdc++ and python: seemingly random errors
Dear gmsh team, I am trying to build gmsh (with occ) using statically linked c++, to be later called from python.
My current setup is loosely based on the configurations I found in:
- https://gitlab.onelab.info/gmsh/gmsh/-/blob/master/.gitlab-ci.yml
- https://gitlab.onelab.info/gmsh/gmsh/-/blob/master/utils/docker/Dockerfile.debian.stretch.64bit
and is composed of the following steps:
- OCC 7.6.0 compilation with
-static-libstdc++
passed to CMAKE_CXX_FLAGS and CMAKE_EXE_LINKER_FLAGS
sed -i "s/pthread rt stdc++/pthread rt/g" adm/cmake/occt_csf.cmake
mkdir build
cd build
cmake \
-DCMAKE_CXX_FLAGS="-static-libstdc++" \
-DCMAKE_EXE_LINKER_FLAGS="-static-libstdc++" \
-DCMAKE_SKIP_RPATH:BOOL=ON \
-DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PREFIX \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_MODULE_ApplicationFramework=0 \
-DBUILD_MODULE_Draw=0 \
-DBUILD_MODULE_Visualization=0 \
..
- gmsh (master as of yesterday morning) compilation with
-static-libstdc++
passed to CMAKE_CXX_FLAGS and CMAKE_EXE_LINKER_FLAGS
mkdir build
cd build
cmake \
-DCMAKE_CXX_FLAGS="-static-libstdc++" \
-DCMAKE_EXE_LINKER_FLAGS="-static-libstdc++" \
-DCMAKE_SKIP_RPATH:BOOL=ON \
-DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PREFIX \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_BUILD_DYNAMIC=1 \
..
Both libraries get compiled correctly, and indeed libstdc++ is statically linked (as one can verify with ldd
).
However, I get seemingly random errors when running gmsh from python. For instance
-
python3 -c 'import gmsh; gmsh.initialize()'
runs successfuly - adding a seemingly innocuous import before gmsh, e.g.
python3 -c 'import matplotlib.pyplot; import gmsh; gmsh.initialize()'
, results in
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "$INSTALL_PREFIX/lib/gmsh.py", line 244, in initialize
raise Exception(logger.getLastError())
Exception
caused by an ierr
with value
1.
- no errors happen when swapping the orders of the imports, i.e.
python3 -c 'import gmsh; import matplotlib.pyplot; gmsh.initialize()'
. Still, that is not a reliable solution for my actual application, because someierr.value != 0
will pop up at later stages of the execution.
How would you suggest to debug this issue?
Thanks