I am trying to compile a program that uses both CUDA and OpenCV. I am sure that the paths to OpenCV are right because compiling a simple OpenCV program with this:
cl /I"%OPENCV_DIR%\include" /LINK"%OPENCV_DIR%\x64\vc10\lib\opencv_core240.lib" "%OPENCV_DIR%\x64\vc10\lib\opencv_highgui240.lib" testCV.cpp
it successfully compiles the program. Now when I try to compile with NVCC like this:
nvcc testCuda.cu --cl-version 2010 --use-local-env -I"%OPENCV_DIR%\include" -L"%OPENCV_DIR%\x64\vc10\lib\opencv_core240.lib" "%OPENCV_DIR%\x64\vc10\lib\opencv_highgui240.lib"
I got an error when trying to link that says:
error LNK2019: unresolved external symbol cvLoadImage referenced in function main
a.exe : fatal error LNK1120: 1 unresolved externals
What am I missing or doing wrong when compiling with NVCC?
May be a missing
-L
before the second library file like the first one?I was just able to link against cuBLAS on Windows by adding a pragma directive to my code:
This might work with OpenCV as well. Be aware that this is non-portable, though.
-L
is used to specify library directories, not files.You probably want to execute:
If that doens't work, drop the
-l
and add their extensions:Once upon a time, when we had CUDA 2.x and OpenCV 2.1, I wrote a Makefile to compile an application that used both frameworks: