I want to use sfml library in ros2 node but when I try to build the code colcon build gives me undefined references sfml function.
I added to compile options on cmake but still nothing has changed.
I am trying to build like $colcon build --packages-select simulator
My Cmake:
[cmake_minimum_required(VERSION 3.5)
project(ais_simulator)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -lsfml-graphics -lsfml-window -lsfml-system)
endif()
# find dependencies
find_package(SFML 2.5
COMPONENTS
system window graphics network audio REQUIRED
)
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(shape_msgs REQUIRED)
add_executable(simulator src/main.cpp)
target_link_libraries(SFMLTest sfml-graphics sfml-audio)
ament_target_dependencies(
simulator
rclcpp
geometry_msgs
shape_msgs
)
install(TARGETS
simulator
DESTINATION lib/${PROJECT_NAME}
)
ament_package()
Package.xml
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ais_simulator</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="ulucaybedir@gmail.com">mbulucay</maintainer>
<license>TODO: License declaration</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>rclcpp</depend>
<depend>geometry_msgs</depend>
<depend>shape_msgs</depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>