在 Ubuntu 15.10 上使用 CUDA 构建 OpenCV3.1 时出错

Error building OpenCV3.1 with CUDA on Ubuntu 15.10

本文关键字:OpenCV3 构建 出错 CUDA Ubuntu      更新时间:2023-10-16

我正在尝试在Linux(Ubuntu 15.10)上构建OpenCV 3.1,但遇到以下错误:

cd /home/rob/Libraries/OpenCV3/opencv-3.1.0/build/modules/cudev/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/opencv_test_cudev.dir/link.txt --verbose=1
/usr/lib/ccache/c++      -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security   -Winit-self -Wpointer-arith   -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -msse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden  -Wno-undef -Wno-missing-declarations -Wno-unused-function -Wno-unused-variable -Wno-enum-compare -Wno-shadow -O3 -DNDEBUG  -DNDEBUG      CMakeFiles/opencv_test_cudev.dir/test_main.cpp.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_lut.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_cvt.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_arithm_op.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_reduction.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_warp.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_color_cvt.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_split_merge.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_pyramids.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_bitwize_op.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_deriv.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_arithm_func.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_integral.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_transpose.cu.o CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_cmp_op.cu.o  -o ../../../bin/opencv_test_cudev  -L/usr/local/cuda/lib64 -rdynamic -lcudart ../../../lib/libopencv_ts.a ../../../lib/libopencv_highgui.so.3.1.0 -ldl -lm -lpthread -lrt ../../../../3rdparty/ippicv/unpack/ippicv_lnx/lib/intel64/libippicv.a -lcudart -lnppc -lnppi -lnpps -lcufft -L/usr/local/cuda/lib64 -lcudart ../../../lib/libopencv_videoio.so.3.1.0 ../../../lib/libopencv_imgcodecs.so.3.1.0 ../../../lib/libopencv_imgproc.so.3.1.0 ../../../lib/libopencv_core.so.3.1.0 ../../../lib/libopencv_cudev.so.3.1.0 -lnppc -lnppi -lnpps -lcufft -Wl,-rpath,/usr/local/cuda/lib64:/home/rob/Libraries/OpenCV3/opencv-3.1.0/build/lib 
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_lut.cu.o: In function `testing::internal::TypeParameterizedTest<LutTest, testing::internal::TemplateSel<LutTest_GpuMat_Test>, testing::internal::Types1<unsigned char> >::Register(char const*, char const*, char const*, int)':
tmpxft_00006387_00000000-10_test_lut.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI7LutTestNS0_11TemplateSelI19LutTest_GpuMat_TestEENS0_6Types1IhEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI7LutTestNS0_11TemplateSelI19LutTest_GpuMat_TestEENS0_6Types1IhEEE8RegisterEPKcSA_SA_i]+0x14b): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_cvt.cu.o: In function `testing::internal::TypeParameterizedTest<CvtTest, testing::internal::TemplateSel<CvtTest_GpuMat_Test>, testing::internal::Types2<int, float> >::Register(char const*, char const*, char const*, int)':
tmpxft_000063d6_00000000-10_test_cvt.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI7CvtTestNS0_11TemplateSelI19CvtTest_GpuMat_TestEENS0_6Types2IifEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI7CvtTestNS0_11TemplateSelI19CvtTest_GpuMat_TestEENS0_6Types2IifEEE8RegisterEPKcSA_SA_i]+0x141): undefined reference to `testing::Message::GetString() const'
tmpxft_000063d6_00000000-10_test_cvt.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI7CvtTestNS0_11TemplateSelI19CvtTest_GpuMat_TestEENS0_6Types2IifEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI7CvtTestNS0_11TemplateSelI19CvtTest_GpuMat_TestEENS0_6Types2IifEEE8RegisterEPKcSA_SA_i]+0x452): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_cvt.cu.o: In function `testing::internal::TypeParameterizedTest<CvtTest, testing::internal::TemplateSel<CvtTest_GpuMat_Test>, testing::internal::Types4<unsigned short, short, int, float> >::Register(char const*, char const*, char const*, int)':
tmpxft_000063d6_00000000-10_test_cvt.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI7CvtTestNS0_11TemplateSelI19CvtTest_GpuMat_TestEENS0_6Types4ItsifEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI7CvtTestNS0_11TemplateSelI19CvtTest_GpuMat_TestEENS0_6Types4ItsifEEE8RegisterEPKcSA_SA_i]+0x152): undefined reference to `testing::Message::GetString() const'
tmpxft_000063d6_00000000-10_test_cvt.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI7CvtTestNS0_11TemplateSelI19CvtTest_GpuMat_TestEENS0_6Types4ItsifEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI7CvtTestNS0_11TemplateSelI19CvtTest_GpuMat_TestEENS0_6Types4ItsifEEE8RegisterEPKcSA_SA_i]+0x472): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_cvt.cu.o:tmpxft_000063d6_00000000-10_test_cvt.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI7CvtTestNS0_11TemplateSelI19CvtTest_GpuMat_TestEENS0_6Types5IhtsifEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI7CvtTestNS0_11TemplateSelI19CvtTest_GpuMat_TestEENS0_6Types5IhtsifEEE8RegisterEPKcSA_SA_i]+0x140): more undefined references to `testing::Message::GetString() const' follow
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_reduction.cu.o: In function `testing::AssertionResult testing::internal::CmpHelperFloatingPointEQ<float>(char const*, char const*, float, float)':
tmpxft_000063c4_00000000-10_test_reduction.compute_20.cudafe1.cpp:(.text._ZN7testing8internal24CmpHelperFloatingPointEQIfEENS_15AssertionResultEPKcS4_T_S5_[_ZN7testing8internal24CmpHelperFloatingPointEQIfEENS_15AssertionResultEPKcS4_T_S5_]+0x12a): undefined reference to `testing::internal::StringStreamToString(std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >*)'
tmpxft_000063c4_00000000-10_test_reduction.compute_20.cudafe1.cpp:(.text._ZN7testing8internal24CmpHelperFloatingPointEQIfEENS_15AssertionResultEPKcS4_T_S5_[_ZN7testing8internal24CmpHelperFloatingPointEQIfEENS_15AssertionResultEPKcS4_T_S5_]+0x139): undefined reference to `testing::internal::StringStreamToString(std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >*)'
tmpxft_000063c4_00000000-10_test_reduction.compute_20.cudafe1.cpp:(.text._ZN7testing8internal24CmpHelperFloatingPointEQIfEENS_15AssertionResultEPKcS4_T_S5_[_ZN7testing8internal24CmpHelperFloatingPointEQIfEENS_15AssertionResultEPKcS4_T_S5_]+0x154): undefined reference to `testing::internal::EqFailure(char const*, char const*, std::string const&, std::string const&, bool)'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_warp.cu.o: In function `testing::AssertionResult testing::internal::CmpHelperEQ<int, int>(char const*, char const*, int const&, int const&)':
tmpxft_000063ba_00000000-10_test_warp.compute_20.cudafe1.cpp:(.text._ZN7testing8internal11CmpHelperEQIiiEENS_15AssertionResultEPKcS4_RKT_RKT0_[_ZN7testing8internal11CmpHelperEQIiiEENS_15AssertionResultEPKcS4_RKT_RKT0_]+0x5c): undefined reference to `testing::internal::EqFailure(char const*, char const*, std::string const&, std::string const&, bool)'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_warp.cu.o: In function `testing::AssertionResult& testing::AssertionResult::operator<< <char [12]>(char const (&) [12])':
tmpxft_000063ba_00000000-10_test_warp.compute_20.cudafe1.cpp:(.text._ZN7testing15AssertionResultlsIA12_cEERS0_RKT_[_ZN7testing15AssertionResultlsIA12_cEERS0_RKT_]+0x66): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_warp.cu.o: In function `testing::AssertionResult& testing::AssertionResult::operator<< <char const*>(char const* const&)':
tmpxft_000063ba_00000000-10_test_warp.compute_20.cudafe1.cpp:(.text._ZN7testing15AssertionResultlsIPKcEERS0_RKT_[_ZN7testing15AssertionResultlsIPKcEERS0_RKT_]+0x67): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_warp.cu.o: In function `testing::AssertionResult& testing::AssertionResult::operator<< <char [7]>(char const (&) [7])':
tmpxft_000063ba_00000000-10_test_warp.compute_20.cudafe1.cpp:(.text._ZN7testing15AssertionResultlsIA7_cEERS0_RKT_[_ZN7testing15AssertionResultlsIA7_cEERS0_RKT_]+0x66): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_warp.cu.o: In function `testing::AssertionResult& testing::AssertionResult::operator<< <std::string>(std::string const&)':
tmpxft_000063ba_00000000-10_test_warp.compute_20.cudafe1.cpp:(.text._ZN7testing15AssertionResultlsISsEERS0_RKT_[_ZN7testing15AssertionResultlsISsEERS0_RKT_]+0x54): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_warp.cu.o: In function `testing::AssertionResult& testing::AssertionResult::operator<< <char [5]>(char const (&) [5])':
tmpxft_000063ba_00000000-10_test_warp.compute_20.cudafe1.cpp:(.text._ZN7testing15AssertionResultlsIA5_cEERS0_RKT_[_ZN7testing15AssertionResultlsIA5_cEERS0_RKT_]+0x66): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_warp.cu.o: In function `testing::AssertionResult testing::internal::CmpHelperEQ<cv::Size_<int>, cv::Size_<int> >(char const*, char const*, cv::Size_<int> const&, cv::Size_<int> const&)':
tmpxft_000063ba_00000000-10_test_warp.compute_20.cudafe1.cpp:(.text._ZN7testing8internal11CmpHelperEQIN2cv5Size_IiEES4_EENS_15AssertionResultEPKcS7_RKT_RKT0_[_ZN7testing8internal11CmpHelperEQIN2cv5Size_IiEES4_EENS_15AssertionResultEPKcS7_RKT_RKT0_]+0x5c): undefined reference to `testing::internal::EqFailure(char const*, char const*, std::string const&, std::string const&, bool)'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_bitwize_op.cu.o: In function `testing::internal::TypeParameterizedTest<LShiftTest, testing::internal::TemplateSel<LShiftTest_Accuracy_Test>, testing::internal::Types1<int> >::Register(char const*, char const*, char const*, int)':
tmpxft_000063f1_00000000-10_test_bitwize_op.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI10LShiftTestNS0_11TemplateSelI24LShiftTest_Accuracy_TestEENS0_6Types1IiEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI10LShiftTestNS0_11TemplateSelI24LShiftTest_Accuracy_TestEENS0_6Types1IiEEE8RegisterEPKcSA_SA_i]+0xdc): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_bitwize_op.cu.o: In function `testing::internal::TypeParameterizedTest<BitNotTest, testing::internal::TemplateSel<BitNotTest_GpuMat_Test>, testing::internal::Types1<int> >::Register(char const*, char const*, char const*, int)':
tmpxft_000063f1_00000000-10_test_bitwize_op.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI10BitNotTestNS0_11TemplateSelI22BitNotTest_GpuMat_TestEENS0_6Types1IiEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI10BitNotTestNS0_11TemplateSelI22BitNotTest_GpuMat_TestEENS0_6Types1IiEEE8RegisterEPKcSA_SA_i]+0x14b): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_bitwize_op.cu.o: In function `testing::internal::TypeParameterizedTest<BitNotTest, testing::internal::TemplateSel<BitNotTest_GpuMat_Test>, testing::internal::Types2<short, int> >::Register(char const*, char const*, char const*, int)':
tmpxft_000063f1_00000000-10_test_bitwize_op.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI10BitNotTestNS0_11TemplateSelI22BitNotTest_GpuMat_TestEENS0_6Types2IsiEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI10BitNotTestNS0_11TemplateSelI22BitNotTest_GpuMat_TestEENS0_6Types2IsiEEE8RegisterEPKcSA_SA_i]+0x140): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_bitwize_op.cu.o: In function `testing::internal::TypeParameterizedTest<BitNotTest, testing::internal::TemplateSel<BitNotTest_GpuMat_Test>, testing::internal::Types3<unsigned short, short, int> >::Register(char const*, char const*, char const*, int)':
tmpxft_000063f1_00000000-10_test_bitwize_op.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI10BitNotTestNS0_11TemplateSelI22BitNotTest_GpuMat_TestEENS0_6Types3ItsiEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI10BitNotTestNS0_11TemplateSelI22BitNotTest_GpuMat_TestEENS0_6Types3ItsiEEE8RegisterEPKcSA_SA_i]+0x140): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_bitwize_op.cu.o: In function `testing::internal::TypeParameterizedTest<BitNotTest, testing::internal::TemplateSel<BitNotTest_GpuMat_Test>, testing::internal::Types4<unsigned char, unsigned short, short, int> >::Register(char const*, char const*, char const*, int)':
tmpxft_000063f1_00000000-10_test_bitwize_op.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI10BitNotTestNS0_11TemplateSelI22BitNotTest_GpuMat_TestEENS0_6Types4IhtsiEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI10BitNotTestNS0_11TemplateSelI22BitNotTest_GpuMat_TestEENS0_6Types4IhtsiEEE8RegisterEPKcSA_SA_i]+0x140): undefined reference to `testing::Message::GetString() const'
CMakeFiles/opencv_test_cudev.dir/opencv_test_cudev_generated_test_bitwize_op.cu.o:tmpxft_000063f1_00000000-10_test_bitwize_op.compute_20.cudafe1.cpp:(.text._ZN7testing8internal21TypeParameterizedTestI10BitAndTestNS0_11TemplateSelI29BitAndTest_GpuMat_GpuMat_TestEENS0_6Types1IiEEE8RegisterEPKcSA_SA_i[_ZN7testing8internal21TypeParameterizedTestI10BitAndTestNS0_11TemplateSelI29BitAndTest_GpuMat_GpuMat_TestEENS0_6Types1IiEEE8RegisterEPKcSA_SA_i]+0x14b): more undefined references to `testing::Message::GetString() const' follow
collect2: error: ld returned 1 exit status
modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/build.make:5441: recipe for target 'bin/opencv_test_cudev' failed
make[2]: *** [bin/opencv_test_cudev] Error 1
make[2]: Leaving directory '/home/rob/Libraries/OpenCV3/opencv-3.1.0/build'
CMakeFiles/Makefile2:1834: recipe for target 'modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/all' failed
make[1]: *** [modules/cudev/test/CMakeFiles/opencv_test_cudev.dir/all] Error 2
make[1]: Leaving directory '/home/rob/Libraries/OpenCV3/opencv-3.1.0/build'
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2

它似乎在一个测试模块中。

使用 CUDA 7.5

、GCC-5.2.1 用于 OpenCV 和 GCC-4.7 用于 CUDA 特定部分(您始终需要使用两个不同的编译器)

有没有人修复或只是一种禁用模块的方法,因为它只是测试?

我遇到了同样的问题。随后,我禁用了使用 cmake 选项"-DBUILD_TESTS=OFF"编译测试模块。然后 opencv 构建似乎没有问题。

希望这有帮助。