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

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

问题描述

我已经在过去与OpenCV的工作在Linux上,但不与CUDA。我用下面的编译错误奋斗了几个月。并尝试了许多解决方案后,我放弃了,并与Windows合作。不过,我真的想在Linux上运行。这是我使用编译opencv_gpu网站上给出的门槛例子命令。

  NVCC`pkg配置--libs opencv` -L。 -L在/ usr /本地/ CUDA / lib目录-lcuda -lcudart`pkg配置--cflags opencv` -I。 -I在/ usr /本地/ CUDA /包括threshold.cpp -o门槛

这里是错误:

  /tmp/tmpxft_0000171b_00000000-1_threshold.o:在函数'主':
。threshold.cpp :(文字+量0x124):未定义的引用`CV :: GPU ::流::空()
。threshold.cpp :(文字+ 0x156):未定义的引用`CV :: GPU ::阈值(CV :: GPU :: GpuMat常量和放大器;,CV :: GPU :: GpuMat和放大器;,双,双,INT,CV: :GPU ::流&安培;)
。threshold.cpp :(文字+ 0x16d):未定义的引用`CV :: GPU :: GpuMat ::下载(CV ::垫&放大器;)常量
/tmp/tmpxft_0000171b_00000000-1_threshold.o:在功能`CV :: GPU :: GpuMat :: GpuMat(CV ::垫常量和放大器;):
threshold.cpp :( text._ZN2cv3gpu6GpuMatC1ERKNS_3MatE [简历:: GPU :: GpuMat :: GpuMat(CV ::垫常量和放大器;)] + 0x63):未定义的引用`CV :: GPU :: GpuMat ::上传(CV: :垫常量和放大器;)
/tmp/tmpxft_0000171b_00000000-1_threshold.o:在功能`CV :: GPU :: GpuMat ::〜GpuMat():
。threshold.cpp :( text._ZN2cv3gpu6GpuMatD1Ev [简历:: GPU :: GpuMat ::〜GpuMat()] + 0xd中):未定义的引用`CV :: GPU :: GpuMat ::版本()'
collect2:劳工处返回1退出状态
使:*** [全部]错误1


解决方案

为了帮助你,我不得不下载和安装的 CUDA 4.0 (带司机4.0.21),然后下载并编译< STRONG> OpenCV的2.3 我的MacBook Pro上的的Mac OS X 10.6.8

通过 OpenCV_GPU 样品code的顺利通过编译我的机器上:

  G ++ threshold.cpp -o门槛'pkg配置--cflags --libs opencv` -lopencv_gpu

您失踪而没有被列入标志 -lopencv_gpu pkg配置

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

here is the error:

/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   

解决方案

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.

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

You were missing the flag -lopencv_gpu , which is not included by pkg-config.

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

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