Gazebo | Ignition | Community
Ask Your Question

Adding environment variable to compile transport code.

asked 2023-03-16 09:15:10 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.


I'm writting some piece of code to extract info from gazebo simulations, making use of a topic that is being published in transport.

My issue is, using the publisher/subscriber CMakeList.txt example file, cmake is unable to find the library file to do its job. I have no clue on which directory CMAKE_PREFIX_PATH should point to, since the only transport11 file I've found is /usr/include/ignition/transport11.

My installation is ignition Fortress from binaries in Ubuntu 20.04, and I've checked with apt that libignition-transport11-dev is installed.

The error message is as follows:

Starting >>> ros_gz_pose_transport
--- stderr: ros_gz_pose_transport                         
CMake Error at CMakeLists.txt:20 (find_package):
  By not providing "Findgz-transport11.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "gz-transport11", but CMake did not find one.

  Could not find a package configuration file provided by "gz-transport11"
  with any of the following names:


  Add the installation prefix of "gz-transport11" to CMAKE_PREFIX_PATH or set
  "gz-transport11_DIR" to a directory containing one of the above files.  If
  "gz-transport11" provides a separate development package or SDK, be sure it
  has been installed.

make: * * * [Makefile:398: cmake_check_build_system] Error 1
Failed   <<< ros_gz_pose_transport [2.06s, exited with code 2]

My CMakeLists.txt is:

cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)

  add_compile_options(-Wall -Wextra -Wpedantic)

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(ignition-cmake2 REQUIRED)

find_package(ignition-plugin1 REQUIRED COMPONENTS register)
set(IGN_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})

# Find the Gazebo Transport library
find_package(gz-transport11 QUIET REQUIRED OPTIONAL_COMPONENTS log)
set(GZ_TRANSPORT_VER ${gz-transport11_VERSION_MAJOR})

find_package(ignition-gazebo6 REQUIRED)
add_library(SampleSystem SHARED src/
set_property(TARGET SampleSystem PROPERTY CXX_STANDARD 17)
  PRIVATE ignition-plugin${IGN_PLUGIN_VER}::ignition-plugin${IGN_PLUGIN_VER}
  PRIVATE ignition-gazebo6::ignition-gazebo6

add_executable(pose_publisher_example src/pose_publisher_example.cpp)
ament_target_dependencies(pose_publisher_example rclcpp geometry_msgs)
add_executable(publish_once src/publish_once.cpp)
ament_target_dependencies(publish_once rclcpp geometry_msgs)
add_executable(hello src/hello_package.cpp)

target_include_directories(pose_publisher_example PUBLIC
target_compile_features(pose_publisher_example PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17


  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)


Thanks in advance, Diego

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2023-03-16 12:30:12 -0500

azeey gravatar image

The ign->gz migration may not be available in the version of libignition-transport11 you have. You need libignition-transport11 11.3.0 to use the gz prefix.

edit flag offensive delete link more


Hi azeey. My transport11 version is 11.4.0. Anyway, if I switch from gz- to ignition- and from GZ_ to IGN_ nothing changes. There should be a directory with the library info to give to cmake anyways, right?

Diego Cubillo gravatar imageDiego Cubillo ( 2023-03-17 04:16:38 -0500 )edit

Once you change the cmake library names to have ignition-, you probably have to clear cmake's cache. The easiest way is to remove the build directory and run cmake again. Have you tried that?

azeey gravatar imageazeey ( 2023-03-21 10:52:18 -0500 )edit

I hadn't, and now it works. Thanks!!!

Diego Cubillo gravatar imageDiego Cubillo ( 2023-03-24 04:15:27 -0500 )edit

Question Tools

1 follower


Asked: 2023-03-16 09:15:10 -0500

Seen: 343 times

Last updated: Mar 16 '23