在linux上编译基本的OpenCV + Cuda程序 [英] Compiling a basic OpenCV + Cuda program on linux

查看:1075
本文介绍了在linux上编译基本的OpenCV + Cuda程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去,我曾经在opencv上使用linux,但不是cuda。我几个月以来遇到以下编译错误。而在尝试了许多解决方案后,我放弃了并与Windows合作。但是,我真的想在linux上工作。这是我用来编译阈值示例在opencv_gpu网站上给出的命令。

I've worked with opencv on linux in the past, but not with cuda. I've struggled with the following compilation error for months. And after trying many solutions i gave up and worked with windows. However, i really want to work on linux. This is the command i'm using to compile the threshold example given on the opencv_gpu website.

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

In order to help you I had to download and install CUDA 4.0 (with driver 4.0.21) and then download and compiled OpenCV 2.3 for my Macbook Pro, on Mac OS X 10.6.8.

OpenCV_GPU 已在我的计算机上成功编译:

The sample code from OpenCV_GPU was successfully compiled on my machine through:

g++ threshold.cpp -o threshold `pkg-config --cflags --libs opencv` -lopencv_gpu

您缺少 pkg-config 不包含的旗标 -lopencv_gpu

这篇关于在linux上编译基本的OpenCV + Cuda程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆