Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Sample build failed with CUDA 5.5 and OpenCV 2.4.6.1

I am trying to use ubuntu 12.04 x64 with CUDA 5.5 Production Release to build OpenCV 2.4.6.1
I can build without sample correctly but when I choose to build sample it will failed with

Linking CXX executable ../../bin/gpu-example-driver_api_stereo_multi
CMakeFiles/example_gpu_driver_api_multi.dir/driver_api_multi.cpp.o: In function `destroyContexts()':
driver_api_multi.cpp:(.text._Z15destroyContextsv+0xc): undefined reference to `cuCtxDestroy_v2'
driver_api_multi.cpp:(.text._Z15destroyContextsv+0x1c): undefined reference to `cuCtxDestroy_v2'
CMakeFiles/example_gpu_driver_api_multi.dir/driver_api_multi.cpp.o: In function `Worker::operator()(int) const':
driver_api_multi.cpp:(.text._ZNK6WorkerclEi+0x19): undefined reference to `cuCtxPushCurrent_v2'
driver_api_multi.cpp:(.text._ZNK6WorkerclEi+0x6bf): undefined reference to `cuCtxPopCurrent_v2'
CMakeFiles/example_gpu_driver_api_multi.dir/driver_api_multi.cpp.o: In function `main':
driver_api_multi.cpp:(.text.startup.main+0x94): undefined reference to `cuInit'
driver_api_multi.cpp:(.text.startup.main+0xb1): undefined reference to `cuDeviceGet'
driver_api_multi.cpp:(.text.startup.main+0xd2): undefined reference to `cuCtxCreate_v2'
driver_api_multi.cpp:(.text.startup.main+0xed): undefined reference to `cuCtxPopCurrent_v2'
driver_api_multi.cpp:(.text.startup.main+0x10d): undefined reference to `cuDeviceGet'
driver_api_multi.cpp:(.text.startup.main+0x12e): undefined reference to `cuCtxCreate_v2'
driver_api_multi.cpp:(.text.startup.main+0x149): undefined reference to `cuCtxPopCurrent_v2'
collect2: ld returned 1 exit status
make[2]: *** [bin/gpu-example-driver_api_multi] Error 1
make[1]: *** [samples/gpu/CMakeFiles/example_gpu_driver_api_multi.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
CMakeFiles/example_gpu_driver_api_stereo_multi.dir/driver_api_stereo_multi.cpp.o: In function `destroyContexts()':
driver_api_stereo_multi.cpp:(.text._Z15destroyContextsv+0xc): undefined reference to `cuCtxDestroy_v2'
driver_api_stereo_multi.cpp:(.text._Z15destroyContextsv+0x1c): undefined reference to `cuCtxDestroy_v2'
CMakeFiles/example_gpu_driver_api_stereo_multi.dir/driver_api_stereo_multi.cpp.o: In function `contextOff()':
driver_api_stereo_multi.cpp:(.text._Z10contextOffv[contextOff()]+0xa): undefined reference to `cuCtxPopCurrent_v2'
CMakeFiles/example_gpu_driver_api_stereo_multi.dir/driver_api_stereo_multi.cpp.o: In function `contextOn(int)':
driver_api_stereo_multi.cpp:(.text._Z9contextOni[contextOn(int)]+0x10): undefined reference to `cuCtxPushCurrent_v2'
CMakeFiles/example_gpu_driver_api_stereo_multi.dir/driver_api_stereo_multi.cpp.o: In function `Worker::operator()(int) const':
driver_api_stereo_multi.cpp:(.text._ZNK6WorkerclEi+0x14): undefined reference to `cuCtxPushCurrent_v2'
driver_api_stereo_multi.cpp:(.text._ZNK6WorkerclEi+0x106): undefined reference to `cuCtxPopCurrent_v2'
CMakeFiles/example_gpu_driver_api_stereo_multi.dir/driver_api_stereo_multi.cpp.o: In function `main':
driver_api_stereo_multi.cpp:(.text.startup.main+0x80b): undefined reference to `cuInit'
driver_api_stereo_multi.cpp:(.text.startup.main+0x822): undefined reference to `cuDeviceGet'
driver_api_stereo_multi.cpp:(.text.startup.main+0x83d): undefined reference to `cuCtxCreate_v2'
driver_api_stereo_multi.cpp:(.text.startup.main+0x85c): undefined reference to `cuDeviceGet'
driver_api_stereo_multi.cpp:(.text.startup.main+0x877): undefined reference to `cuCtxCreate_v2'
collect2: ld returned 1 exit status

It seems like forgetting link libcudart, I think this can be fixed by modifying CMakeLists.txt but I don't know how to fix it.