使用OpenCV构建WebRTC

时间:2017-03-18 12:30:41

标签: opencv webrtc libstdc++

我正在尝试使用OpenCV构建WebRTC。我用cmake构建了OpenCV并安装它。在PeerConnection示例中,我包含了opencv libs和headers。当我打电话给忍者时,我得到以下错误:

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.

我的gcc版本是5.4.0。 找到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

我猜cmake opencv使用/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21 和webrtc忍者似乎使用libstdc ++。so.6.0.16。这可能会导致冲突。这种冲突的错误原因是什么?如果是,我该如何解决?

1 个答案:

答案 0 :(得分:0)

此问题与WebRTC与系统中的库之间的libc和libstdc ++库的不兼容版本有关。

解决方案是复制两个文件并重建软链接

  • 首先,将/usr/lib/x86_64-linux-gnu/libstdc++.so.6.xx复制到此路径/ WebRTC / Path / src / build / linux / debian_wheezy_amd64-sysroot / usr / lib / x86_64-linux- gnu并重建libstdc ++。so.6链接以指向新复制的库
  • 其次,将/lib/x86_64-linux-gnu/libc-xx.so复制到/ WebRTC / Path // home / faraklit / projects / webrtc-checkout / src / build / linux / debian_wheezy_amd64-sysroot / lib / x86_64 -linux-GNU 并重建libc.so.6链接以指向新复制的库