我在使用 opencv4tegra 编译标准 opencv 示例时遇到了相当大的困难 - 按照 Jetson TK1 的 nvidia wiki 的指示进行安装。
出于沮丧,我从 2.4.10.1 源代码构建了 opencv,并将其直接安装到/usr/local...并且效果非常好!在我卸载它之后,我在针对他们的编译时遇到了同样的问题,所以显然这是我正在做的事情。有趣的是,我可以针对他们的 opencv4tegra 库运行已编译的示例应用程序,但我无法针对他们的库进行编译。
测试环境:
我没有更改 opencv 2.4.10.1 版本中的示例文件 - 它是相同的stereo_match.cpp 文件。我只是想编译它。
这些函数位于 gpu.hpp 文件内 - 我已经看过了。我也跑过:
nm /usr/lib/libopencv_gpu.so | grep StereoBM_GPU | c++filt
...只是为了确保符号在库中。
这是怎么回事??所以,它显然没有链接 - 但我无法弄清楚 g++ 想要什么......
$:~/opencv/samples/gpu$
g++ -I/usr/include -L/usr/local/cuda/lib `pkg-config opencv --libs` stereo_match.cpp -o stereo_m
/tmp/ccvj1IgD.o: In function
App::App(Params const&)': stereo_match.cpp:(.text+0x8b0): undefined reference to
cv::gpu::StereoBM_GPU::StereoBM_GPU()' stereo_match.cpp:(.text+0x8c6): undefined reference tocv::gpu::StereoBeliefPropagation::StereoBeliefPropagation(int, int, int, int)' stereo_match.cpp:(.text+0x8e0): undefined reference to
cv::gpu::StereoConstantSpaceBP::StereoConstantSpaceBP(int, int, int, int, int)' stereo_match.cpp:(.text+0x8e4): undefined reference tocv::gpu::getDevice()' stereo_match.cpp:(.text+0x8ec): undefined reference to
cv::gpu::printShortCudaDeviceInfo(int)' /tmp/ccvj1IgD.o: In functionApp::run()': stereo_match.cpp:(.text+0xa42): undefined reference to
cv::imread(std::string const&, int)' stereo_match.cpp:(.text+0xa70): undefined reference tocv::imread(std::string const&, int)' stereo_match.cpp:(.text+0xb90): undefined reference to
cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0xba0): undefined reference tocv::_OutputArray::_OutputArray(cv::Mat&)' stereo_match.cpp:(.text+0xbb4): undefined reference to
cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)' stereo_match.cpp:(.text+0xbc4): undefined reference tocv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0xbd4): undefined reference to
cv::_OutputArray::_OutputArray(cv::Mat&)' stereo_match.cpp:(.text+0xbe8): undefined reference tocv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)' stereo_match.cpp:(.text+0xbfa): undefined reference to
cv::gpu::GpuMat::upload(cv::Mat const&)' stereo_match.cpp:(.text+0xc0c): undefined reference tocv::gpu::GpuMat::upload(cv::Mat const&)' stereo_match.cpp:(.text+0xc3e): undefined reference to
cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0xc4e): undefined reference tocv::imshow(std::string const&, cv::_InputArray const&)' stereo_match.cpp:(.text+0xc94): undefined reference to
cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0xca4): undefined reference tocv::imshow(std::string const&, cv::_InputArray const&)' stereo_match.cpp:(.text+0xdaa): undefined reference to
cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0xdba): undefined reference tocv::_OutputArray::_OutputArray(cv::Mat&)' stereo_match.cpp:(.text+0xdce): undefined reference to
cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)' stereo_match.cpp:(.text+0xdde): undefined reference tocv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0xdee): undefined reference to
cv::_OutputArray::_OutputArray(cv::Mat&)' stereo_match.cpp:(.text+0xe02): undefined reference tocv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)' stereo_match.cpp:(.text+0xe4e): undefined reference to
cv::gpu::GpuMat::upload(cv::Mat const&)' stereo_match.cpp:(.text+0xe60): undefined reference tocv::gpu::GpuMat::upload(cv::Mat const&)' stereo_match.cpp:(.text+0xe92): undefined reference to
cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0xea2): undefined reference tocv::imshow(std::string const&, cv::_InputArray const&)' stereo_match.cpp:(.text+0xee8): undefined reference to
cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0xef8): undefined reference tocv::imshow(std::string const&, cv::_InputArray const&)' stereo_match.cpp:(.text+0xf22): undefined reference to
cv::gpu::Stream::Null()' stereo_match.cpp:(.text+0xf34): undefined reference tocv::gpu::StereoBM_GPU::operator()(cv::gpu::GpuMat const&, cv::gpu::GpuMat const&, cv::gpu::GpuMat&, cv::gpu::Stream&)' stereo_match.cpp:(.text+0xf4c): undefined reference to
cv::gpu::Stream::Null()' stereo_match.cpp:(.text+0xf5e): undefined reference tocv::gpu::StereoBeliefPropagation::operator()(cv::gpu::GpuMat const&, cv::gpu::GpuMat const&, cv::gpu::GpuMat&, cv::gpu::Stream&)' stereo_match.cpp:(.text+0xf76): undefined reference to
cv::gpu::Stream::Null()' stereo_match.cpp:(.text+0xf88): undefined reference tocv::gpu::StereoConstantSpaceBP::operator()(cv::gpu::GpuMat const&, cv::gpu::GpuMat const&, cv::gpu::GpuMat&, cv::gpu::Stream&)' stereo_match.cpp:(.text+0xfa0): undefined reference to
cv::gpu::GpuMat::download(cv::Mat&) const' stereo_match.cpp:(.text+0xff6): undefined reference tocv::putText(cv::Mat&, std::string const&, cv::Point_<int>, int, double, cv::Scalar_<double>, int, int, bool)' stereo_match.cpp:(.text+0x1032): undefined reference to
cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0x1042): undefined reference tocv::imshow(std::string const&, cv::_InputArray const&)' stereo_match.cpp:(.text+0x105c): undefined reference to
cv::waitKey(int)' /tmp/ccvj1IgD.o: In functionApp::handleKey(char)': stereo_match.cpp:(.text+0x1630): undefined reference to
cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0x1640): undefined reference tocv::_OutputArray::_OutputArray(cv::Mat&)' stereo_match.cpp:(.text+0x1654): undefined reference to
cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)' stereo_match.cpp:(.text+0x1664): undefined reference tocv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0x1674): undefined reference to
cv::_OutputArray::_OutputArray(cv::Mat&)' stereo_match.cpp:(.text+0x1688): undefined reference tocv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)' stereo_match.cpp:(.text+0x169a): undefined reference to
cv::gpu::GpuMat::upload(cv::Mat const&)' stereo_match.cpp:(.text+0x16ac): undefined reference tocv::gpu::GpuMat::upload(cv::Mat const&)' stereo_match.cpp:(.text+0x1718): undefined reference to
cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0x1728): undefined reference tocv::imshow(std::string const&, cv::_InputArray const&)' stereo_match.cpp:(.text+0x176e): undefined reference to
cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0x177e): undefined reference tocv::imshow(std::string const&, cv::_InputArray const&)' /tmp/ccvj1IgD.o: In function
cv::Mat::~Mat()': stereo_match.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x20): undefined reference tocv::fastFree(void*)' /tmp/ccvj1IgD.o: In function
cv::Mat::operator=(cv::Mat const&)': stereo_match.cpp:(.text.ZN2cv3MataSERKS0[ZN2cv3MataSERKS0]+0xa2): undefined reference tocv::Mat::copySize(cv::Mat const&)' /tmp/ccvj1IgD.o: In function
cv::Mat::create(int, int, int)': stereo_match.cpp:(.text._ZN2cv3Mat6createEiii[_ZN2cv3Mat6createEiii]+0x66): undefined reference tocv::Mat::create(int, int const*, int)' /tmp/ccvj1IgD.o: In function
cv::Mat::release()': stereo_match.cpp:(.text._ZN2cv3Mat7releaseEv[ZN2cv3Mat7releaseEv]+0x30): undefined reference tocv::Mat::deallocate()' /tmp/ccvj1IgD.o: In function
cv::gpu::GpuMat::GpuMat(cv::Size, int)': stereo_match.cpp:(.text._ZN2cv3gpu6GpuMatC2ENS_5Size_IiEEi[_ZN2cv3gpu6GpuMatC5ENS_5Size_IiEEi]+0x5c): undefined reference tocv::gpu::GpuMat::create(int, int, int)' /tmp/ccvj1IgD.o: In function
cv::gpu::GpuMat::~GpuMat()': stereo_match.cpp:(.text._ZN2cv3gpu6GpuMatD2Ev[_ZN2cv3gpu6GpuMatD5Ev]+0xa): undefined reference tocv::gpu::GpuMat::release()' /tmp/ccvj1IgD.o: In function
App::workBegin()': stereo_match.cpp:(.text._ZN3App9workBeginEv[_ZN3App9workBeginEv]+0x8): undefined reference tocv::getTickCount()' /tmp/ccvj1IgD.o: In function
App::workEnd()': stereo_match.cpp:(.text._ZN3App7workEndEv[_ZN3App7workEndEv]+0x8): undefined reference tocv::getTickCount()' stereo_match.cpp:(.text._ZN3App7workEndEv[_ZN3App7workEndEv]+0x20): undefined reference to
cv::getTickFrequency()' collect2: error: ld returned 1 exit status
最佳答案
请参阅 cmake 指令中的宏以在 opencv 中进行打包,并坚持使用 make。再次感谢您提供线索“Iwillnotexist Idonotexist”。
就我而言,我错过了两个依赖项: /modules/gpu/src/nvidia &&/modules/gpu/src/nvidia/core ...其他部分也提到了“非自由”。
隐藏的依赖项...天哪。
感谢所有贡献的回复 - 现在看起来微不足道。
关于c++ - opencv4tegra : issues compiling sample stereo_match. cpp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29265370/