c++ - opencv4tegra : issues compiling sample stereo_match. cpp

标签 c++ opencv nvidia tegra

我在使用 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 to 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): undefined reference to cv::_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 to 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): undefined reference to 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): undefined reference to 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): undefined reference to 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): undefined reference to 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): undefined reference to cv::_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 to 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): undefined reference to 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): undefined reference to 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): undefined reference to 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): undefined reference to 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): undefined reference to 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): undefined reference to cv::_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 to 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): undefined reference to 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): undefined reference to 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): undefined reference to cv::fastFree(void*)' /tmp/ccvj1IgD.o: In functioncv::Mat::operator=(cv::Mat const&)': stereo_match.cpp:(.text.ZN2cv3MataSERKS0[ZN2cv3MataSERKS0]+0xa2): undefined reference to 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): undefined reference to 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): undefined reference to cv::gpu::GpuMat::release()' /tmp/ccvj1IgD.o: In functionApp::workBegin()': stereo_match.cpp:(.text._ZN3App9workBeginEv[_ZN3App9workBeginEv]+0x8): undefined reference to 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

最佳答案

请参阅 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/

相关文章:

c++ - 使用 OpenCV 写入/dev/fb0

docker - 如何从 Docker 容器连接到 Nvidia MPS 服务器?

memory - CL_OUT_OF_RESOURCES 用于 1GB VRAM 的 200 万个 float ?

c++ - 如何在TEdit控件中设置textalignment

c++ - 我如何在 C++ 中表示数字 2^1000?

c++ - Boost::Geometry:如何在 multi_polygon 中连接相交的多边形?

python - OpenCV dilate() 函数没有缩小所有方向的间隙

c# - 如何将整数从 C# 方法复制到 native C DLL 函数

Android JNI C++ 段错误

CUDA 可视化分析器无法完成执行。将 X Config 选项 'Interactive' 设置为 false 的建议解决方案不起作用