So, it seems that I’ve found the issue. The TorchConfig.cmake has this piece of config:
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(TORCH_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=0")
endif()
Which forces GCC to use the old C++11 ABI. Is there any reason why libtorch is being built using the old ABI ? Because what happens is that every single dependency that I have on my project such as leveldb or grpc for instance, won’t be able to be linked because they were compiled with the newer C++11 ABI. And I guess that this is the most common situation for other projects.
If I manually change GLIBCXX_USE_CXX11_ABI=1 and recompile the entire libtorch by myself, it works just fine, but that requires a lot of manual steps that aren’t quite easy to integrate into my CMake file. Not to mention that it’s really hard to figure out how to compile the libtorch correctly.
Are there any plans to move to the newer C++11 ABI and thus allow other dependencies to be linked without problems ? Otherwise, people will have a lot of trouble to depend on the libtorch libraries.
So as far as I know, the C++ library is extracted from the Python packages.
Those, in turn, are - I think - build with “manylinux” in mind, which specifies archaic compatibility requirements.
Note that it is a variable to be filled in in the template - indeed, I seem to get =1 by default when compiling from source.
we have that flag set because we build with gcc 4.9.x, which only has the old ABI.
In GCC 5.1, the ABI for std::string was changed, and binaries compiling with gcc >= 5.1 are not ABI-compatible with binaries build with gcc < 5.1 (like pytorch) unless you set that flag.
Thank you all for the answers ! I’ll compile the libtorch library with the new ABI set because otherwise, I’ll have to recompile all other libraries to the old ABI. I guess there is no other way to get around this dual ABI problem.
Aside from downloading the new Libtorch versions, is it necessary to add something else to the CMake file? I ask because I replaced my old version with the nightly version, and I am still getting the same error when building my project.