CXX11 ABI incompatibility when using Open3D + ROS + PyTorch/Tensorflow together
zhoupengwei opened this issue · 5 comments
Do you have better suggestions to solve the link error with other libraries?eg. ros undefined reference to `ros::init(int&, char**, std::string const&, unsigned int)'
Describe the bug
Errors occur when Open3D library is linked together with ros.
To Reproduce
Steps to reproduce the behavior:
When I want to use the latest version to develop with the ROS system, I encountered a link error
- catkin build
- undefined reference to `ros::init(int&, char**, std::string const&, unsigned int)'
Expected behavior
The code should compile and work on major platforms including Windows, macOS and linux.
Environment (please complete the following information):
- Operating system:
Ubuntu 18.04 - Python version:
Python 3.8 - Open3D version:
0.12.0 - Is this remote workstation?:
no - How did you install Open3D?:
build from source - Compiler version (if built from source):
gcc 9.3
Additional context
I have successfully used open3d 0.10.0 and ROS to develop laser slam before. Now when I update to the latest version, I encounter some link errors related to the ROS system, such as undefined reference to ros::init(int&, char**, std::string const&, unsigned int). After we search the relevant errors, like 2286. This error can be corrected by setting cmake flag -DGLIBCXX_USE_CXX11_ABI=ON. Unfortunately, this will make it impossible to compile open3d_ML modules, because they do not use C + + 11ABI both TensorFlow and PyTorch, as shown in note. cmake -DGLIBCXX_USE_CXX11_ABI=ON -DBUILD_TENSORFLOW_OPS=ON
will lead to errors simultaneously. Is there any better solution instead of set the cmake flag? I want to use the open3d_ML module at the same time.
@benjaminum I see that libtorch
has builds available both with and without the CXX11_ABI. Is libtorch
sufficient for building Open3D instead of the full PyTorch? Something similar may be possible for Tensorflow, but I don't see a Tensorflow binary release with CXX11 ABI.
@zpw6106 Is it possible to build ROS with -D_GLIBCXX_USE_CXX11_ABI=0
?
@ssheorey At present, it is impossible to do that, this leads to the link errors. I still haven't solved it.
Sry for the late reply @zpw6106 . libtorch should be sufficient but will require changes to the cmake files. There could be problems using an op library linking to libtorch with a different ABI than the pytorch libs.
For tensorflow you could check if the tensorflow in the anaconda channel uses the ABI you need.
@zpw6106 If you build either PyTorch or Tensorflow from source with the new CXX11_ABI, i.e. with _GLIBCXX_USE_CXX11_ABI=1
this combination of libraries will work, since Open3D now builds with _GLIBCXX_USE_CXX11_ABI=1
by default.
Closing this issue since it is up to PyTorch / TF to update their default build options.