2

我在使用 opencv4tegra 编译标准 opencv 示例时遇到了相当大的困难 - 按照 nvidia wiki 为 Jetson TK1 的指示安装。

出于沮丧,我从 2.4.10.1 源代码构建了 opencv,并将其直接安装到 /usr/local... 并且效果很好!在我卸载它之后,我在编译他们的问题时遇到了同样的问题,所以很明显这是我正在做的事情。有趣的是,我可以针对他们的 opencv4tegra lib 运行编译后的示例应用程序……但我无法针对他们的 lib 进行编译。

测试环境:

我没有从 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: 在函数App::App(Params const&)': stereo_match.cpp:(.text+0x8b0): undefined reference to cv::gpu::StereoBM_GPU::StereoBM_GPU()' stereo_match.cpp:(.text+0x8c6): 未定义引用 cv::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 to cv::gpu::getDevice()' stereo_match.cpp:(.text+0x8ec): undefined reference tocv::gpu::printShortCudaDeviceInfo(int)' /tmp/ccvj1IgD.o: In function App::run()': stereo_match.cpp:(.text+0xa42): undefined reference tocv::imread(std:: string const&, int)' stereo_match.cpp:(.text+0xa70): undefined reference to cv::imread(std::string const&, int)' stereo_match.cpp:(.text+0xb90): undefined reference tocv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0xba0): undefined reference to cv::_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): 未定义引用 cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0xbd4): undefined reference to cv::_OutputArray::_OutputArray(cv::Mat&)' stereo_match.cpp:(.text+0xbe8): 未定义对 cv::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): 未定义引用 cv::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): 未定义引用 cv::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): 未定义引用 cv::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): 未定义引用 cv::_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): 未定义对 cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0xdee): undefined reference to cv::_OutputArray::_OutputArray(cv::Mat&)' stereo_match.cpp 的引用:(.text+0xe02): 未定义的引用cv::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 to cv::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): 未定义引用 cv::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): 未定义引用 cv::imshow(std::string const&, cv::_InputArray const&)' stereo_match.cpp:(.text+0xf22): undefined reference to cv::gpu::Stream::Null ()' stereo_match.cpp:(.text+0xf34): 未定义引用cv::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): 未定义引用 cv::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 to cv::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):未定义的引用 cv::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 to cv::imshow(std::string const&, cv::_InputArray const&)' stereo_match.cpp:(.text+0x105c): undefined reference to cv::waitKey(int)' /tmp/ccvj1IgD.o: In function App::handleKey(char)': stereo_match.cpp:(.text+0x1630): undefined reference tocv::_InputArray ::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0x1640): undefined reference to cv::_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): 未定义引用 cv::_InputArray::_InputArray(cv::Mat const&)' stereo_match.cpp:(.text+0x1674): undefined reference to cv::_OutputArray::_OutputArray(cv::Mat&)' stereo_match.cpp:(.text+0x1688): 未定义引用 cv::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): 未定义引用 cv::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): 未定义引用 cv::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 to cv::imshow(std::string const&, cv::_InputArray const&)' /tmp/ccvj1IgD.o: In functioncv::Mat::~Mat()': stereo_match.cpp:(.text._ZN2cv3MatD2Ev [_ZN2cv3MatD5Ev]+0x20):对cv::fastFree(void*)' /tmp/ccvj1IgD.o: In functioncv::Mat::operator=(cv::Mat const&)' 的未定义引用:stereo_match.cpp:(. text.ZN2cv3MataSERKS0 [ ZN2cv3MataSERKS0 ]+0xa2):对cv::Mat::copySize(cv::Mat const&)' /tmp/ccvj1IgD.o: In functioncv::Mat的未定义引用::create(int, int, int)': stereo_match.cpp:(.text._ZN2cv3Mat6createEiii[_ZN2cv3Mat6createEiii]+0x66): undefined reference to cv::Mat::create(int, int const*, int)' /tmp/ccvj1IgD.o: In functioncv::Mat::release()': stereo_match.cpp:(.text. _ZN2cv3Mat7releaseEv[ ZN2cv3Mat7releaseEv]+0x30): 未定义对cv::Mat::deallocate()' /tmp/ccvj1IgD.o: In functioncv::gpu::GpuMat::GpuMat(cv::Size ) 的引用, int)': stereo_match.cpp:(.text._ZN2cv3gpu6GpuMatC2ENS_5Size_IiEEi[_ZN2cv3gpu6GpuMatC5ENS_5Size_IiEEi]+0x5c): undefined reference to cv::gpu::GpuMat::create(int, int, int)' /tmp/ccvj1IgD.o: In functioncv::gpu::GpuMat::~GpuMat()': stereo_match.cpp:(.text._ZN2cv3gpu6GpuMatD2Ev[_ZN2cv3gpu6GpuMatD5Ev ]+0xa):对cv::gpu::GpuMat::release()' /tmp/ccvj1IgD.o: In functionApp::workBegin()' 的未定义引用:stereo_match.cpp:(.text._ZN3App9workBeginEv[_ZN3App9workBeginEv]+0x8):对cv::getTickCount()' /tmp/ccvj1IgD.o: In functionApp::workEnd()' 的未定义引用:stereo_match.cpp:(.text ._ZN3App7workEndEv[_ZN3App7workEndEv]+0x8): undefined reference to cv::getTickCount()' stereo_match.cpp:(.text._ZN3App7workEndEv[_ZN3App7workEndEv]+0x20): undefined reference tocv::getTickFrequency()' collect2: error: ld returned 1 exit status

4

1 回答 1

2

请参阅 cmake 中的宏指令以在 opencv 中进行打包并坚持使用 make。再次感谢线索'Iwillnotexist Idonotexist'。

就我而言,我错过了两个依赖项:/modules/gpu/src/nvidia && /modules/gpu/src/nvidia/core ...并且在其他部分引用了“非自由”。

隐藏依赖的东西......哦,男孩。

感谢所有贡献的回复 - 现在似乎微不足道。

于 2015-03-26T22:33:00.670 回答