Do you have any suggestions on how we could fix the issue with loading Gmsh in Slicer?
Analysis
The library libgmsh.so.4.11
shipped in the gmsh wheel references std::__cxx11::basic_string
See details
$ readelf -W -s ~/Downloads/gmsh-4.11.1-py2.py3-none-manylinux1_x86_64/gmsh-4.11.1.data/data/lib/libgmsh.so.4.11 | \
cut -c60- | c++filt | ack "::basic_string" | head -n1
std::__cxx11::basic_string<char, std::char_traits, std::allocator >::assign(char const*)@GLIBCXX_3.4.21 (5)
cxx11::basic_string
$ readelf -W -s ~/Downloads/gmsh-4.11.1-py2.py3-none-manylinux1_x86_64/gmsh-4.11.1.data/data/lib/libgmsh.so.4.11 |
cut -c60- | c++filt | ack “cxx11::basic_string” | wc -l
364
std::basic_string
$ readelf -W -s ~/Downloads/gmsh-4.11.1-py2.py3-none-manylinux1_x86_64/gmsh-4.11.1.data/data/lib/libgmsh.so.4.11 |
cut -c60- | c++filt | ack “std::basic_string” | wc -l
0
whereas the libraries associated with the Slicer release references std::basic_string
See details
$ readelf -W -s ~/Downloads/Slicer-5.2.2-linux-amd64/lib/Slicer-5.2/libMRMLCore.so | \
cut -c60- | c++filt | ack "::basic_string" | head -n1
slicer_itk::ProcessObject::RemoveInput(std::basic_string<char, std::char_traits, std::allocator > const&)
cxx11::basic_string
$ readelf -W -s ./bin/libMRMLCore.so |
cut -c60- | c++filt | ack “cxx11::basic_string” | wc -l
1310
std::basic_string
$ readelf -W -s ./bin/libMRMLCore.so |
cut -c60- | c++filt | ack “std::basic_string” | wc -l
0
I suspect this is due to incompatibility associated with the Dual ABI introduced in gcc 5.
[…] since GCC 5 there are two implementations of std::string
available in libstdc++. The two implementations are not link-compatible (they have different mangled names, so can’t be linked together) but can co-exist in the same binary (they have different mangled names, so don’t conflict if one object uses std::string
and the other uses std::__cxx11::string
). If your objects use std::string
then usually they should all be compiled with the same string implementation. Compile with -D_GLIBCXX_USE_CXX11_ABI=0
to select the original gcc4-compatible
implementation, or -D_GLIBCXX_USE_CXX11_ABI=1
to select the new cxx11
implementation (don’t be fooled by the name, it can be used in C++03 too, it’s called cxx11
because it conforms to the C++11 requirements).
Source: https://stackoverflow.com/questions/46746878/is-it-safe-to-link-c17-c14-and-c11-objects/49119902#49119902
Aren’t manylinux1 wheels suppose to use _GLIBCXX_USE_CXX11_ABI=0
?
Yes, there are suppose to be compatible.
The problem is that the process to generate the gmsh
wheels does not seem to be compliant as it is re-packaging its SDK.
Source: https://gitlab.onelab.info/gmsh/gmsh/-/blob/master/.gitlab-ci.yml#L436
Does this mean initializing the library on Slicer compiled a newer system compiler work ?
Yes, assuming this is the only issue, this should indeed work.
See details
That said, attempting to initialize the library still lead to a segfault.
There are likely additional symbol clashes to be investigated.
Path forward
As mentioned by @lassoan , considering that the library is distributed under the term of a copyleft (non-permissive) license, I suggest you consider reaching out to one of the commercial partner listed here.
The steps would be to revamp the build-system of gmsh to build compliant wheels (e.g by leveraging https://scikit-build.org & relevant manylinux docker image)