Issues linking with libtorch (C++11 ABI?)

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.

3 Likes