You are not logged in.

#1 2020-01-01 21:46:02

JohnGood
Member
Registered: 2020-01-01
Posts: 2

C++ ABI issue when trying to compile my project on Arch

I am trying to compile my project using many libraries (opencv, cuda, jsoncpp, protobuf and more) on ArchLinux.
It builds successfully on Centos 7 but I endup with this error on Arch Linux:

/usr/bin/ld: /usr/lib/libopencv_gapi.so.4.2.0: undefined reference to `std::runtime_error::runtime_error(std::runtime_error&&)@GLIBCXX_3.4.26'
/usr/bin/ld: /usr/lib/libjsoncpp.so: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()@GLIBCXX_3.4.26'
/usr/bin/ld: /usr/lib/libopencv_gapi.so.4.2.0: undefined reference to `std::logic_error::logic_error(std::logic_error&&)@GLIBCXX_3.4.26'
/usr/bin/ld: /usr/lib/libopencv_gapi.so.4.2.0: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()@GLIBCXX_3.4.26'
collect2: error: ld returned 1 exit status

I believe this means one of the libraries was compiled with the pre-g++5 ABI which can be achieve with the preprocessing macro: _GLIBCXX_USE_CXX11_ABI=0.
On Centos7 the entire project and all the Centos7 libraries are built with _GLIBCXX_USE_CXX11_ABI=0.
On Arch Linux it seems that all libraries are build with _GLIBCXX_USE_CXX11_ABI=1.

So I compiled my project with _GLIBCXX_USE_CXX11_ABI=1 as well and used cuda 10.2 instead of 10.0.
I tried compiling it with _GLIBCXX_USE_CXX11_ABI=0 but I ended up with way more errors, with others libraries.

I'm using only official packages from pacman in their latest version (including cuda, jsoncpp and opencv).

I do not understand which library creates the issue nor why. Could you give me some hints to debug it?

Last edited by JohnGood (2020-01-01 21:50:04)

Offline

#2 2020-01-02 05:53:23

crondog
Member
Registered: 2011-04-21
Posts: 130

Re: C++ ABI issue when trying to compile my project on Arch

I'm not very familiar with cuda, however I found this https://bugs.archlinux.org/task/63408

Closed by  Sven-Hendrik Haase (Svenstaro)
Friday, 06 September 2019, 22:20 GMT
Reason for closing:  Fixed
Additional comments about closing:  Closing as this is now confirmed to be an issue of mixing gcc8 and gcc9 ABI. Can be solved using cuda by building native code using gcc9 and then use gcc8 as the nvcc host compiler only.

It looks like you will need to rework your build system to pick the correct compilers

Offline

#3 2020-01-02 15:22:23

JohnGood
Member
Registered: 2020-01-01
Posts: 2

Re: C++ ABI issue when trying to compile my project on Arch

Thank you! That explains it perfectly. I did not know gcc9 ABI has a breaking change like gcc5 had.

That means it should no longer be possible to use cuda on Arch Linux with official packages as the latest cuda version is using gcc8. The only solution for me is to recompile all the open source libraries or wait for NVidia to compile cuda with gcc9.

Offline

#4 2020-01-20 17:12:56

Archrumbz
Member
Registered: 2020-01-20
Posts: 1

Re: C++ ABI issue when trying to compile my project on Arch

Thank you. I just solved a similar issue.

I was trying to link code with CUDA 10.2 compiled by gcc8, which  opencv and vtk compiled from gcc9. I had a fresh installation of Arch, so the solution was to find gcc8 pre-compiled versions of opencv, openexr, imbase and vtk in the archives https://archive.archlinux.org/packages and install with

pacman -U <package>.pkg.tar.xz

.

Offline

Board footer

Powered by FluxBB