FS#63408 - [cuda][gcc8] can't link to opencv compiled with GCC 9

Attached to Project: Community Packages
Opened by Andrew A (andrew-wja) - Thursday, 08 August 2019, 15:30 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Friday, 06 September 2019, 22:20 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Konstantin Gizdov (kgizdov)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description:

opencv-4.1.1-1 does not dynamically link successfully against the current glibcxx.

/usr/bin/ld: /usr/lib/libopencv_videoio.so.4.1.1: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()@GLIBCXX_3.4.26'

It looks like the dynamic library just needs to be rebuilt against the current glibcxx.

The immediately previous version of the package, opencv-4.1.0-2 does not exhibit this issue.

Additional info:
* package version(s)
opencv-4.1.1-1, glibc-2.29-4, gcc-9.1.0-2

Steps to reproduce:

Try to build any application which needs to link opencv, for example, any of the opencv examples.
This task depends upon

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.
Comment by huyizheng (huyizheng) - Wednesday, 14 August 2019, 10:41 GMT
Same here. Trying to compile pytorch 1.2.0, when using opencv 4.1.1 I got these errors, downgrade opencv to 4.1.0 then no errors occurred.
Comment by Antonio Rojas (arojas) - Saturday, 24 August 2019, 22:44 GMT
Can you please point me to a specific opencv example that fails to build? I just compiled digikam, gmic, zart and a couple of opencv samples without any issue.
Comment by Sven-Hendrik Haase (Svenstaro) - Thursday, 29 August 2019, 01:56 GMT
Well, pytorch does indeed fail to compile since the opencv update.
Comment by Antonio Rojas (arojas) - Thursday, 29 August 2019, 06:31 GMT
I was hoping for a simpler test case since the OP claims this also happens with opencv's own samples
Comment by DarcyHu (DarcyHu) - Saturday, 31 August 2019, 06:22 GMT
I got similar error when building mxnet. I use PKGBUILD from https://github.com/archlinuxcn/repo/tree/master/archlinuxcn/mxnet. To reproduce, add ArchLinuxCN repo according to https://github.com/archlinuxcn/repo, and build it with `archlinuxcn-x86_64-build`.
Comment by Antonio Rojas (arojas) - Saturday, 31 August 2019, 07:44 GMT
Can anybody reproduce this with anything that does *not* involve CUDA?
Comment by Antonio Rojas (arojas) - Saturday, 31 August 2019, 08:33 GMT
Alright, so here's the problem:

> c++filt _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev
std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()

> nm -D /usr/lib/libstdc++.so | grep _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev
00000000001387b0 W _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev

> nm -D /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/libstdc++.so.6 | grep _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev

So nothing wrong with opencv. It's just using symbols from gcc9's libstdc++, which are not available in gcc8's one. Not sure how you would fix this besides providing your own opencv-cuda compiled with GCC 8.
Comment by DarcyHu (DarcyHu) - Saturday, 31 August 2019, 09:08 GMT
hmmm, so any suggestion to solve this issue? AFAIK, pytorch, tensorlfow both use gcc 8 as compiler, because cuda 10 depends on gcc 8.
Comment by DarcyHu (DarcyHu) - Saturday, 31 August 2019, 14:03 GMT
@Svenstaro cuda 10.1.243 remove the gcc version checking, see `/opt/cuda/targets/x86_64-linux/include/crt/host_config.h`. Could we build pytorch with gcc 9?
Comment by Konstantin Gizdov (kgizdov) - Saturday, 31 August 2019, 15:37 GMT
We tried shipping CUDA with GCC 9 and it doesn't work. So no. I will hopefully provide a different solution very soon.

Loading...