I am currently working on developing a test program for ROS using melodic on Ubuntu 18.04, and I am still a beginner, but I am searching for Google.I'm trying to work with the GUI app in shared memory by obtaining (C++) a program that I can refer to from others and adding a shm_open() function to it.However, the following error appears in catkin_make.I assume that the target_link_libraries failed because I have included it.
[96%] Built target img_node
/usr/bin/ld:CMakeFiles/parking_control.dir/src/parking_control.cpp.o: Undefined reference to symbol 'shm_open@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/librt.so.1:error adding symbols:DSO missing from command line
collect2:error:ld returned1 exit status
carrier/carrier_parking/CMakeFiles/parking_control.dir/build.make:495:recipe for target'/home/texeng/catkin_ws/develop/lib/carrier_parking/parking_control'failed
make[2]:***[/home/texeng/catkin_ws/develop/lib/carrier_parking/parking_control] Error 1
CMakeFiles/Makefile2:6774: recipe for target'carrier/carrier_parking/CMakeFiles/parking_control.dir/all'failed
make[1]:***[carrier/carrier_parking/CMakeFiles/parking_control.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: ***[all] Error 2
Invoking "make-j8-l8" failed
Could you teach me how to link this shm_open()?
If you want to compile the original source code, you can compile it with "g++-o myshm mushm.cpp-lrt" and I don't know how to write this compilation option "-lrt" = RealtimeExtensions library in ROS CMakeLists.txt.I apologize for the inconvenience, but please let me know.
# Oira is an amateur cmake
so I'm sorry if I'm wrong
According to https://stackoverflow.com/questions/31147129/, shm_open()
should be in librt.a
or librt.so
, so
TARGET_LINK_LIBRARIES(my_app${Boost_LIBRARIES}rt)
You can add rt
to the end of target_link_libraries
as shown in .
Huh? So, isn't add_library
more handsome?(Not Tested)
Thank you very much for teaching me.
It was solved by adding rt.
target_link_libraries(my_app${catkin_LIBRARIES}rt)
That's all.
© 2024 OneMinuteCode. All rights reserved.