Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Using SFML librariy in ros2 node  (Read 676 times)

0 Members and 1 Guest are viewing this topic.

mbulucay

  • Newbie
  • *
  • Posts: 1
    • View Profile
Using SFML librariy in ros2 node
« on: June 30, 2022, 06:35:42 pm »
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>
 
« Last Edit: July 01, 2022, 11:18:45 pm by eXpl0it3r »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Using SFML librariy in ros2 node
« Reply #1 on: July 01, 2022, 11:22:32 pm »
And what are the errors?

You btw shouldn't manually add link statements to the compiler options
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/