我过去在linux上使用过opencv,但没有使用过cuda。几个月来我一直在与以下编译错误作斗争。在尝试了许多解决方案后,我放弃并使用 Windows。不过,我真的很想在 Linux 上工作。这是我用来编译 opencv_gpu 网站上给出的阈值示例的命令。
nvcc `pkg-config --libs opencv` -L. -L/usr/local/cuda/lib -lcuda -lcudart `pkg-config --cflags opencv` -I. -I/usr/local/cuda/include threshold.cpp -o threshold
这是错误:
/tmp/tmpxft_0000171b_00000000-1_threshold.o: In function `main':
threshold.cpp:(.text+0x124): undefined reference to `cv::gpu::Stream::Null()'
threshold.cpp:(.text+0x156): undefined reference to `cv::gpu::threshold(cv::gpu::GpuMat const&, cv::gpu::GpuMat&, double, double, int, cv::gpu::Stream&)'
threshold.cpp:(.text+0x16d): undefined reference to `cv::gpu::GpuMat::download(cv::Mat&) const'
/tmp/tmpxft_0000171b_00000000-1_threshold.o: In function `cv::gpu::GpuMat::GpuMat(cv::Mat const&)':
threshold.cpp:(.text._ZN2cv3gpu6GpuMatC1ERKNS_3MatE[cv::gpu::GpuMat::GpuMat(cv::Mat const&)]+0x63): undefined reference to `cv::gpu::GpuMat::upload(cv::Mat const&)'
/tmp/tmpxft_0000171b_00000000-1_threshold.o: In function `cv::gpu::GpuMat::~GpuMat()':
threshold.cpp:(.text._ZN2cv3gpu6GpuMatD1Ev[cv::gpu::GpuMat::~GpuMat()]+0xd): undefined reference to `cv::gpu::GpuMat::release()'
collect2: ld returned 1 exit status
make: *** [all] Error 1
为了帮助你,我必须下载并安装CUDA 4.0(使用驱动4.0.21)然后下载并编译OpenCV 2.3对于我的 Macbook Pro,Mac OS X 10.6.8.
示例代码来自OpenCV_GPU http://opencv.willowgarage.com/wiki/OpenCV_GPU通过以下方式在我的机器上成功编译:
g++ threshold.cpp -o threshold `pkg-config --cflags --libs opencv` -lopencv_gpu
你错过了旗帜-lopencv_gpu
,不包括在pkg 配置.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)