MATLAB Answers

using cmake, I got a ploblem compile made by gpu coder static library(.a)

44 views (last 30 days)
I wannna compile including static library(.a) function made by gpu coder in jetson xavier and execute code on ROS.
I already successed making static library using gpu coder.
I think that in CMakeLists, setting library path is well.
but I got a ploblem when complile .cpp file through cmake in Xavier.
I attach error code and CMakeLists file.
help me!!!!!
/home/nvidia/catkin_ws/src/realtime_inpainting/src/wrapper/wrapper.a(wrapper.o): In function `__sti____cudaRegisterAll()':
tmpxft_00002175_00000000-5_wrapper.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_42_tmpxft_00002175_00000000_6_wrapper_cpp1_ii_96e8f507'
/home/nvidia/catkin_ws/src/realtime_inpainting/src/wrapper/wrapper.a(introsort.o): In function `__sti____cudaRegisterAll()':
tmpxft_0000244e_00000000-5_introsort.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_44_tmpxft_0000244e_00000000_6_introsort_cpp1_ii_5da2a824'
/home/nvidia/catkin_ws/src/realtime_inpainting/src/wrapper/wrapper.a(insertionsort.o): In function `__sti____cudaRegisterAll()':
tmpxft_000024cb_00000000-5_insertionsort.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_48_tmpxft_000024cb_00000000_6_insertionsort_cpp1_ii_54501cbc'
/home/nvidia/catkin_ws/src/realtime_inpainting/src/wrapper/wrapper.a(heapsort.o): In function `__sti____cudaRegisterAll()':
tmpxft_00002530_00000000-5_heapsort.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_43_tmpxft_00002530_00000000_6_heapsort_cpp1_ii_6b1ad24e'
/home/nvidia/catkin_ws/src/realtime_inpainting/src/wrapper/wrapper.a(wrapper_emxutil.o): In function `__sti____cudaRegisterAll()':
tmpxft_0000259e_00000000-5_wrapper_emxutil.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_50_tmpxft_0000259e_00000000_6_wrapper_emxutil_cpp1_ii_74fbff25'
/home/nvidia/catkin_ws/src/realtime_inpainting/src/wrapper/wrapper.a(MWLaunchParametersUtilities.o): In function `__sti____cudaRegisterAll()':
tmpxft_000026fb_00000000-5_MWLaunchParametersUtilities.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_62_tmpxft_000026fb_00000000_6_MWLaunchParametersUtilities_cpp1_ii_3d5deff9'
/home/nvidia/catkin_ws/src/realtime_inpainting/src/wrapper/wrapper.a(wrapper_data.o): In function `__sti____cudaRegisterAll()':
tmpxft_000020c9_00000000-5_wrapper_data.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_47_tmpxft_000020c9_00000000_6_wrapper_data_cpp1_ii_7c19101b'
/home/nvidia/catkin_ws/src/realtime_inpainting/src/wrapper/wrapper.a(wrapper_initialize.o): In function `__sti____cudaRegisterAll()':
tmpxft_0000210a_00000000-5_wrapper_initialize.cudafe1.cpp:(.text.startup+0x20): undefined reference to `__cudaRegisterLinkedBinary_53_tmpxft_0000210a_00000000_6_wrapper_initialize_cpp1_ii_9c24d7b2'
[ 84%] Built target stereoimageproc_exe
collect2: error: ld returned 1 exit status
realtime_inpainting/CMakeFiles/inpainting_cuda.dir/build.make:137: recipe for target '/home/nvidia/catkin_ws/devel/lib/realtime_inpainting/inpainting_cuda' failed
make[2]: *** [/home/nvidia/catkin_ws/devel/lib/realtime_inpainting/inpainting_cuda] Error 1
CMakeFiles/Makefile2:7382: recipe for target 'realtime_inpainting/CMakeFiles/inpainting_cuda.dir/all' failed
make[1]: *** [realtime_inpainting/CMakeFiles/inpainting_cuda.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 86%] Built target tf2_ros_static_transform_publisher
[ 87%] Built target kinect2_bridge
[ 87%] Built target image_rotate
[ 93%] Built target depth_image_proc
[ 94%] Built target kinect2_bridge_nodelet
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j8 -l8" failed

Accepted Answer

Chao Luo
Chao Luo on 23 Apr 2020
Hi DaHoon,
The static library created by GPU Coder contains reallocatable CUDA device code, that can only be linked by nvcc. g++ cannot link CUDA device code. To fix this issue, you can use nvcc instead of g++ to link. Or use GPU Coder to create a dynamic library (.so), where the device code has already been linked by nvcc, that you can use g++ to link.
Chao
  7 Comments
Vlasov Aleksandr
Vlasov Aleksandr on 18 Apr 2021
Excuse me, I don't understand how to link to libconsole_bridge.so. I can't find anything useful on the Internet, could you tell me which command can do this?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!