1
votes

I am trying to build WebRTC with OpenCV. I built OpenCV with cmake and make installed it. In PeerConnection example i included opencv libs and headers. when i call ninja build i get the following error:

ninja -C out/Default
ninja: Entering directory `out/Default'
[1/16] LINK ./peerconnection_client
FAILED: peerconnection_client 
../../third_party/llvm-build/Release+Asserts/bin/clang++ -L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core -ldl -lm -lpthread -lrt -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -lpthread -Wl,--as-needed -fuse-ld=gold -B../../third_party/binutils/Linux_x64/Release/bin -Wl,--threads -Wl,--thread-count=4 -Wl,--icf=all -m64 -pthread -Werror --sysroot=../../build/linux/debian_wheezy_amd64-sysroot -L/home/parallels/webrt_blog/src/build/linux/debian_wheezy_amd64-sysroot/lib/x86_64-linux-gnu -Wl,-rpath-link=/home/parallels/webrt_blog/src/build/linux/debian_wheezy_amd64-sysroot/lib/x86_64-linux-gnu -L/home/parallels/webrt_blog/src/build/linux/debian_wheezy_amd64-sysroot/usr/lib/x86_64-linux-gnu -Wl,-rpath-link=/home/parallels/webrt_blog/src/build/linux/debian_wheezy_amd64-sysroot/usr/lib/x86_64-linux-gnu -L/home/parallels/webrt_blog/src/build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6 -Wl,-rpath-link=/home/parallels/webrt_blog/src/build/linux/debian_wheezy_amd64-sysroot/usr/lib/gcc/x86_64-linux-gnu/4.6 -L/home/parallels/webrt_blog/src/build/linux/debian_wheezy_amd64-sysroot/usr/lib -Wl,-rpath-link=/home/parallels/webrt_blog/src/build/linux/debian_wheezy_amd64-sysroot/usr/lib -Wl,-rpath-link=. -Wl,--disable-new-dtags -Wl,-rpath=\$ORIGIN/. -Wl,-rpath-link=. -Wl,--export-dynamic -o "./peerconnection_client" -Wl,--start-group @"./peerconnection_client.rsp" ./libboringssl.so ./libprotobuf_lite.so -Wl,--end-group  -lX11 -lXcomposite -lXext -lXrender -ldl -lrt -lgmodule-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lfreetype -lfontconfig -lgthread-2.0 -lglib-2.0 -lexpat -lm 
/usr/local/lib/libopencv_objdetect.so: error: undefined reference to 'std::__throw_out_of_range_fmt(char const*, ...)', version 'GLIBCXX_3.4.20'
/usr/local/lib/libopencv_stitching.so: error: undefined reference to 'std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_stringstream()', version 'GLIBCXX_3.4.21'
/usr/local/lib/libopencv_shape.so: error: undefined reference to 'memcpy', version 'GLIBC_2.14'
/usr/local/lib/libopencv_stitching.so: error: undefined reference to 'std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream(std::_Ios_Openmode)', version 'GLIBCXX_3.4.21'
/usr/local/lib/libopencv_stitching.so: error: undefined reference to 'std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const', version 'GLIBCXX_3.4.21'
/usr/local/lib/libopencv_flann.so: error: undefined reference to 'std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)', version 'GLIBCXX_3.4.21'
/usr/local/lib/libopencv_flann.so: error: undefined reference to 'std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()', version 'GLIBCXX_3.4.21'
/usr/local/lib/libopencv_flann.so: error: undefined reference to 'std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)', version 'GLIBCXX_3.4.21'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

My gcc version is 5.4.0. Result of locate libstdc++.so.6 :

/home/parallels/webrt_blog/rootfs/usr/lib/arm-linux-gnueabihf/libstdc++.so.6
/home/parallels/webrt_blog/rootfs/usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.17
/home/parallels/webrt_blog/src/build/linux/debian_wheezy_amd64-sysroot/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/home/parallels/webrt_blog/src/build/linux/debian_wheezy_amd64-sysroot/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.17
/home/parallels/webrt_blog/src/build/linux/debian_wheezy_arm-sysroot/usr/lib/arm-linux-gnueabihf/libstdc++.so.6
/home/parallels/webrt_blog/src/build/linux/debian_wheezy_arm-sysroot/usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.17
/home/parallels/webrt_blog/src/build/linux/debian_wheezy_i386-sysroot/usr/lib/i386-linux-gnu/libstdc++.so.6
/home/parallels/webrt_blog/src/build/linux/debian_wheezy_i386-sysroot/usr/lib/i386-linux-gnu/libstdc++.so.6.0.17
/home/parallels/webrt_blog/src/build/linux/ubuntu_precise_amd64-sysroot/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/home/parallels/webrt_blog/src/build/linux/ubuntu_precise_amd64-sysroot/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
/home/parallels/webrt_blog/src/third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6
/home/parallels/webrtc/rootfs/usr/lib/arm-linux-gnueabihf/libstdc++.so.6
/home/parallels/webrtc/rootfs/usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.17
/home/parallels/webrtc/src/build/linux/debian_wheezy_amd64-sysroot/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/home/parallels/webrtc/src/build/linux/debian_wheezy_amd64-sysroot/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.17
/home/parallels/webrtc/src/build/linux/debian_wheezy_arm-sysroot/usr/lib/arm-linux-gnueabihf/libstdc++.so.6
/home/parallels/webrtc/src/build/linux/debian_wheezy_arm-sysroot/usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.17
/home/parallels/webrtc/src/build/linux/debian_wheezy_i386-sysroot/usr/lib/i386-linux-gnu/libstdc++.so.6
/home/parallels/webrtc/src/build/linux/debian_wheezy_i386-sysroot/usr/lib/i386-linux-gnu/libstdc++.so.6.0.17
/home/parallels/webrtc/src/build/linux/ubuntu_precise_amd64-sysroot/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/home/parallels/webrtc/src/build/linux/ubuntu_precise_amd64-sysroot/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
/home/parallels/webrtc/src/third_party/llvm-build/Release+Asserts/lib/libstdc++.so.6
/opt/rpi_tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/arm-bcm2708-linux-gnueabi/sysroot/lib/libstdc++.so.6
/opt/rpi_tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/arm-bcm2708-linux-gnueabi/sysroot/lib/libstdc++.so.6.0.17
/opt/rpi_tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/arm-bcm2708-linux-gnueabi/sysroot/lib/libstdc++.so.6.0.17-gdb.py
/opt/rpi_tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot/lib/libstdc++.so.6
/opt/rpi_tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot/lib/libstdc++.so.6.0.17
/opt/rpi_tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot/lib/libstdc++.so.6.0.17-gdb.py
/opt/rpi_tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot/lib/libstdc++.so.6
/opt/rpi_tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot/lib/libstdc++.so.6.0.20
/opt/rpi_tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot/lib/libstdc++.so.6.0.20-gdb.py
/opt/rpi_tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/lib/libstdc++.so.6
/opt/rpi_tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/lib/libstdc++.so.6.0.19
/opt/rpi_tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/lib/libstdc++.so.6.0.19-gdb.py
/opt/rpi_tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/lib/libstdc++.so.6
/opt/rpi_tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/lib/libstdc++.so.6.0.19
/opt/rpi_tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/lib/libstdc++.so.6.0.19-gdb.py
/usr/lib/parallels-tools/installer/iagent32/libs/libstdc++.so.6
/usr/lib/parallels-tools/installer/iagent32/libs/libstdc++.so.6/libstdc++.so.6
/usr/lib/parallels-tools/installer/iagent64/libs/libstdc++.so.6
/usr/lib/parallels-tools/installer/iagent64/libs/libstdc++.so.6/libstdc++.so.6
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21-gdb.py

I guess cmake opencv uses /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 and webrtc ninja seems to use libstdc++.so.6.0.16. This may cause a conflict.Is the reason of the error this conflict? If yes how can i resolve it?

1

1 Answers

0
votes

This problem is about the incompatible version of libc and libstdc++ libraries between WebRTC and the libraries in the system.

Solution is to copy two files and rebuild the soft links

  • First, copy /usr/lib/x86_64-linux-gnu/libstdc++.so.6.xx to this path /WebRTC/Path/src/build/linux/debian_wheezy_amd64-sysroot/usr/lib/x86_64-linux-gnu and rebuild the libstdc++.so.6 link to point to the new copied library
  • Secondly, copy /lib/x86_64-linux-gnu/libc-xx.so to /WebRTC/Path//home/faraklit/projects/webrtc-checkout/src/build/linux/debian_wheezy_amd64-sysroot/lib/x86_64-linux-gnu and rebuild the libc.so.6 link to point to the new copied library