I'm working in a ROS project using WebRTC as well.
My problem is when I try to build my project, I get this:
/usr/bin/ld: /home/carlos/Documentos/ROS_WebRTC/catkin_ws/src/libwebrtc/out/lib/libwebrtc.a(thread_pthread.o): undefined symbol reference 'pthread_rwlock_wrlock@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
Searching in other posts with the similar problem, I've come to a conclusion I have to add CMAKE FLAG "-pthread"
to g++.
Using VERBOSE=1
with catkin_make
I realize that, in fact, the .cc file which causes the problem need that flag. But I don't know how add it.
I have tried with set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lpthread")
but it doesn't fix anything.
This is my CMakeFiles.txt:
cmake_minimum_required(VERSION 2.8.3)
project(webrtcbridge)
add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
rospy
genmsg
)
find_package(LibWebRTC REQUIRED)
catkin_package()
include_directories(
include ${catkin_INCLUDE_DIRS}
)
include_directories(
include ${LIBWEBRTC_USE_FILE}
)
add_executable(webrtcbridge_node src/webrtcbridge_node.cc)
target_link_libraries (webrtcbridge_node ${catkin_LIBRARIES})
target_link_libraries (webrtcbridge_node ${LIBWEBRTC_LIBRARIES})
And this is a piece of verbose got executing catkin_make:
/usr/bin/c++ CMakeFiles/webrtcbridge_node.dir/src/webrtcbridge_node.cc.o -o /home/carlos/Documentos/ROS_WebRTC/catkin_ws/devel/lib/webrtcbridge/webrtcbridge_node -rdynamic /opt/ros/kinetic/lib/libroscpp.so -lboost_signals -lboost_filesystem /opt/ros/kinetic/lib/librosconsole.so /opt/ros/kinetic/lib/librosconsole_log4cxx.so /opt/ros/kinetic/lib/librosconsole_backend_interface.so -llog4cxx -lboost_regex /opt/ros/kinetic/lib/libxmlrpcpp.so /opt/ros/kinetic/lib/libroscpp_serialization.so /opt/ros/kinetic/lib/librostime.so /opt/ros/kinetic/lib/libcpp_common.so -lboost_system -lboost_thread -lboost_chrono -lboost_date_time -lboost_atomic -lpthread -lconsole_bridge /home/carlos/Documentos/ROS_WebRTC/catkin_ws/src/libwebrtc/out/lib/libwebrtc.a -lSM -lICE -lX11 -lXext -ldl -lrt -Wl **"here should be -pthread I think"**,-rpath,/opt/ros/kinetic/lib
Any idea about set "pthread" at the end?