Ask Your Question
0

Sample build failed with CUDA 5.5 and OpenCV 2.4.6.1

asked 2013-08-13 03:23:42 -0600

Gianluigi gravatar image

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.

edit retag flag offensive close merge delete

Comments

The driver API examples are CUDA based examples using the specific NVIDIA GPU API. It is possible that these need extra functionality from NVIDIA itself or that you haven't got a card that can use this functionality.

Do the other examples build correctly?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-13 03:30:11 -0600 )edit

No, when make detect error it will just leave... Is there a way to build sample only?

Gianluigi gravatar imageGianluigi ( 2013-08-13 21:14:55 -0600 )edit

Yes, include the sample file in a empty project, add all linker dependencies, then build it yourself.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-14 00:52:48 -0600 )edit

I choose another way, I comment "add_subdirectory(gpu)" in "opencv-2.4.6.1/samples/CMakeLists.txt" than it can be build successfully

Gianluigi gravatar imageGianluigi ( 2013-08-14 01:13:00 -0600 )edit
1

I add "-L/usr/local/cuda/lib64 -lcuda" to "opencv-2.4.6.1/build/samples/gpu/CMakeFiles/example_gpu_driver_api_multi.dir/link.txt" and it can be build correct, but next target gpu-example-driver_api_stereo_multi will still failed. I think there should be a way to modify CMakeLists.txt to add this to every target, but I have no idea about cmake

Gianluigi gravatar imageGianluigi ( 2013-08-14 02:01:03 -0600 )edit

Please make a bug report about this and about your solution at the bug report section. Developers will try to find a solution for it then.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-14 02:07:11 -0600 )edit

Thanks, I've reported it

Gianluigi gravatar imageGianluigi ( 2013-08-14 02:21:06 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2013-08-14 02:31:09 -0600

Gianluigi gravatar image

I found the solution, just modify line 39
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})
to
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_GPU_SAMPLES_REQUIRED_DEPS} cuda)
in "opencv-2.4.6.1/samples/gpu/CMakeLists.txt" can easily fix this problem

edit flag offensive delete link more

Comments

It would be nice if you could supply a pull request for the problem. Look at the contribute page for more information.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-14 02:39:39 -0600 )edit
1

Thank you for this solution. It works like a gem.

AnirudhPuligandla gravatar imageAnirudhPuligandla ( 2017-08-29 10:19:08 -0600 )edit

Question Tools

Stats

Asked: 2013-08-13 03:23:42 -0600

Seen: 2,384 times

Last updated: Aug 14 '13