title: What does this strange "/usr/bin/ld: cannot find -lXAW_LIBRARY-NOTFOUND" error mean?
body: <p>I created a ROS2 rviz plugin in C++ which I need to compile into a <strong>shared</strong> library (<code>.so</code>) using cmake. I already have a working CMakeLists.txt (see below) which creates a <strong>static</strong> library (<code>.a</code>); I need it to be shared, though.</p>
  
  <p>However, when I add the <code>SHARED</code> keyword to the <code>add_library</code> macro (commented out in the code below), it throws this strange error:</p>
  
  <pre><code>/usr/bin/ld: cannot find -lXAW_LIBRARY-NOTFOUND
  </code></pre>
  
  <p>Now, I have looked at the many "/usr/bin/ld: cannot find <em>[some library]</em>" questions here on SO (like <a href="https://stackoverflow.com/questions/5329638/usr-bin-ld-cannot-find">this</a>), but my error seems to be more strange since it seems to contain an error ("<code>-lXAW_LIBRARY-NOTFOUND</code>") IN THE error (/usr/bin/ld: cannot find...). I mean, why is he even looking for a library called LIBRARY_NOTFOUND??</p>
  
  <p>I'm on Ubuntu xenial 16.04 using cmake 3.10.</p>
  
  <p><strong>CMakeLists.txt:</strong></p>
  
  <pre><code>project(traffic_sign_delegation_manager)
  
  set(CMAKE_CXX_STANDARD 17)
  
  if(NOT WIN32)
    add_definitions(-fPIC)
  endif()
  
  if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    add_compile_options(-Wall -Wextra -Wpedantic -Wno-deprecated-declarations)
  endif()
  
  set(CMAKE_INCLUDE_CURRENT_DIR ON)
  set(CMAKE_AUTOMOC ON)
  
  find_package(ament_cmake REQUIRED)
  find_package(rclcpp REQUIRED)
  find_package(rviz_common REQUIRED)
  find_package(std_msgs REQUIRED)
  find_package(rosidl_default_generators REQUIRED)
  find_package(rosidl_generator_cpp)
  find_package(pluginlib REQUIRED)
  
  find_package(Qt5Core REQUIRED)
  find_package(Qt5Gui REQUIRED)
  find_package(Qt5OpenGL REQUIRED)
  find_package(Qt5 REQUIRED COMPONENTS Widgets)
  
  set(msg_files
    "msg/TrafficSignList.msg"
    "msg/TrafficSign.msg"
    "msg/TrafficSignSetList.msg"
    "msg/TrafficSignSet.msg"
    "msg/TrafficSignSetStatus.msg"
    "msg/TrafficSignsManaged.msg"
    "msg/AccLever2.msg"
    "msg/VehicleOdometry.msg"
  )
  
  rosidl_generate_interfaces(${PROJECT_NAME}
    ${msg_files}
    DEPENDENCIES std_msgs
  )
  
  link_directories(${ament_cmake_LIBRARY_DIRS})
  
  add_definitions(-DQT_NO_KEYWORDS)
  
  qt5_wrap_ui(QT_UI_FILES ui/traffic_sign_delegation_manager_panel.ui)
  qt5_wrap_ui(QT_UI_FILES ui/traffic_sign_list_item.ui)
  
  qt5_add_resources(QT_QRC_FILES ui/traffic_sign_delegation_manager.qrc)
  
  set_property(SOURCE traffic_sign_delegation_manager_panel.h PROPERTY SKIP_AUTOMOC ON)
  set_property(SOURCE draw_area.h PROPERTY SKIP_AUTOMOC ON)
  set_property(SOURCE adv_interaction_groupbox.h PROPERTY SKIP_AUTOMOC ON)
  set_property(SOURCE traffic_sign_delegation_manager_display.h PROPERTY SKIP_AUTOMOC ON)
  
  add_library(delegator_lib   # SHARED # &lt;=== WHY IS THIS NOT WORKING?
    vec2d.cpp
    vec2d.h
    traffic_sign_delegation_manager_panel.cpp
    traffic_sign_delegation_manager_panel.h
    draw_area.cpp
    draw_area.h
    traffic_sign_delegation_manager_display.cpp
    traffic_sign_delegation_manager_display.h
    adv_interaction_groupbox.cpp
    adv_interaction_groupbox.h
    ui/traffic_sign_list_item.ui
    ui/traffic_sign_delegation_manager_panel.ui
    ${QT_UI_FILES}
    ${MOC_FILES}
  )
  
  rosidl_target_interfaces(delegator_lib ${PROJECT_NAME} "rosidl_typesupport_cpp")
  
  target_include_directories(delegator_lib PUBLIC
    ${rvizCommon_DIR}
    ${rosidl_generator_cpp_INCLUDE_DIRS}
    ${ament_cmake_INCLUDE_DIRS}
    ${rviz2_INCLUDE_DIRS}
    ${rviz_common_INCLUDE_DIRS}
    ${FREETYPE_INCLUDE_DIRS}
    ${Qt5_INCLUDE_DIRS}
  )
  
  target_link_libraries(delegator_lib
    rviz_common::rviz_common
  )
  
  target_compile_definitions(delegator_lib PRIVATE "RVIZ_DEFAULT_PLUGINS_BUILDING_LIBRARY")
  target_compile_definitions(delegator_lib PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")
  
  pluginlib_export_plugin_description_file(rviz_common plugin_description.xml)
  
  ament_target_dependencies(delegator_lib
    geometry_msgs
    laser_geometry
    nav_msgs
    map_msgs
    rclcpp
    resource_retriever
    urdf
    visualization_msgs
  )
  
  ament_export_include_directories(${INCLUDE_DIRS} ${ament_cmake_INCLUDE_DIRS} include)
  ament_export_interfaces(delegator_lib HAS_LIBRARY_TARGET)
  
  ament_export_dependencies(
    Qt5
    rviz_common
    geometry_msgs
    laser_geometry
    map_msgs
    nav_msgs
    rclcpp
    urdf
    visualization_msgs
    rosidl_generator_cpp
  )
  
  install(FILES plugin_description.xml
    DESTINATION share/${PROJECT_NAME})
  install(DIRECTORY images
    DESTINATION share/${PROJECT_NAME})
  install(DIRECTORY ui
    DESTINATION share/${PROJECT_NAME}
    PATTERN "*.ui"
    EXCLUDE)
  
  install(
    TARGETS delegator_lib
    EXPORT delegator_lib
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin
    INCLUDES DESTINATION include
  )
  
  install(
    DIRECTORY "${CMAKE_SOURCE_DIR}/icons"
    DESTINATION "share/${PROJECT_NAME}"
  )
  
  ament_package()
  </code></pre>
  
  <p><em>Please note: This question is not about ROS; I am not a cmake wizard, so probably I'm just doing something terribly wrong in cmake... I already asked <a href="https://answers.ros.org/question/314576/porting-rviz-plugin-to-rviz2-cmake-trouble/" rel="nofollow noreferrer">a more broad version of this question</a> on <code>answers.ros</code>, but it appears to be too cmake-specific or something. Anyway, I did not get an answer there. (The above code is not an MWE, sorry; I could create one if neccessary, but it would require ROS2 to compile...)</em></p>