Linking error OpenCV 2.4+CUDA windows 7(x64) command line
command-line, cuda, opencv, visual-c++, windows-7-x64
Solution
`-L` is used to specify library directories, not files.
You probably want to execute:
nvcc testCuda.cu --cl-version 2010 --use-local-env -I"%OPENCV_DIR%\include" -L"%OPENCV_DIR%\x64\vc10\lib" -lopencv_core240 -lopencv_highgui240
If that doens't work, drop the `-l` and add their extensions:
nvcc testCuda.cu --cl-version 2010 --use-local-env -I"%OPENCV_DIR%\include" -L"%OPENCV_DIR%\x64\vc10\lib" opencv_core240.lib opencv_highgui240.lib
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:
CXX=g++
CUDA_INSTALL_PATH=/usr/local/cuda
CFLAGS= -I. -I$(CUDA_INSTALL_PATH)/include -I/usr/include/opencv
LDFLAGS= -L$(CUDA_INSTALL_PATH)/lib -lcudart -L/usr/lib -lcxcore -lcv -lhighgui -lcvaux -lml
ifdef EMU
CUDAFLAGS+=-deviceemu
endif
all:
$(CXX) $(CFLAGS) -c main.cpp -o main.o -m32 -arch i386
nvcc $(CUDAFLAGS) -c kernel_gpu.cu -o kernel_gpu.o
$(CXX) $(LDFLAGS) main.o kernel_gpu.o -o grayscale -arch i386
clean:
rm -f *.o grayscale
Problem
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?