Compiling a basic OpenCV + Cuda program on linux

前端 未结 3 1667
后悔当初
后悔当初 2021-01-07 03:55

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

相关标签:
3条回答
  • 2021-01-07 04:15

    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.

    0 讨论(0)
  • 2021-01-07 04:16

    Instead of using pkg-config in the nvcc line I would suggest just manually pointing the compiler at the opencv library and include files. Perhaps you could just run pkg-config --libs opencv on the command line and copy the necessary libs into your nvcc command. It seems nvcc is only choking on the opencv libs (it can't find them for sure!).

    0 讨论(0)
  • 2021-01-07 04:21

    This looks like a linker problem. I don't know, if nvcc follows the same conventions as gcc, but I would try:

    nvcc `pkg-config --cflags opencv` -L. -L/usr/local/cuda/lib -I. -I/usr/local/cuda/include -o threshold threshold.cpp `pkg-config --libs opencv` -lcuda -lcudart

    More in general: If you write

    gcc t.cpp -lB -lA

    it means that libB depends on symbols from libA; t.cpp can depend on symbols from libA and libB.

    0 讨论(0)
提交回复
热议问题