title: Undefined Symbol Reference 'pthread_rwlock_wrlock@@GLIBC_2.2.5'
body: <p>I'm working in a ROS project using WebRTC as well.</p>
  
  <p>My problem is when I try to build my project, I get this:</p>
  
  <pre><code>/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
  </code></pre>
  
  <p>Searching in other posts with the similar problem, I've come to a conclusion I have to add <code>CMAKE FLAG "-pthread"</code> to g++.</p>
  
  <p>Using <code>VERBOSE=1</code> with <code>catkin_make</code> I realize that, in fact, the .cc file which causes the problem need that flag. But I don't know how add it.</p>
  
  <p>I have tried with <code>set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lpthread")</code> but it doesn't fix anything.</p>
  
  <p>This is my CMakeFiles.txt:</p>
  
  <pre><code>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})
  </code></pre>
  
  <p>And this is a piece of verbose got executing catkin_make:</p>
  
  <p><code>/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</code> </p>
  
  <p>Any idea about set "pthread" at the end?</p>