I solved the problem. I use vscode with debugging however there was a problem. I deleted install and build folders and rebuild it. It solved after rebuild.
Package A a_library
cmake_minimum_required(VERSION 3.8)
project(package_A)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(b_library REQUIRED)
set(dependencies
rclcpp
std_msgs
)
include_directories(include)
add_library(a_library SHARED src/a_library.cpp )
ament_target_dependencies(a_library ${dependencies} b_library)
add_executable(a_node src/a_node.cpp)
ament_target_dependencies(a_node ${dependencies} b_library)
target_link_libraries(a_node a_library)
install(TARGETS a_node a_library
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()
Package B b_library
cmake_minimum_required(VERSION 3.8)
project(package_B)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
set(dependencies
rclcpp
std_msgs
)
include_directories(include)
add_library(b_library SHARED src/b_library.cpp)
ament_target_dependencies(b_library ${dependencies})
ament_export_libraries(b_library)
ament_export_include_directories(include)
install(
DIRECTORY include/
DESTINATION include
)
install(
TARGETS b_library
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()
Could you post what you have tried so far and the error message that you are getting? It certainly will be easier to narrow it down that way.
Have you tried this out?: https://stackoverflow.com/questions/5...
Roberto your post is also usefull but there are many question stackoverflow and answers.ros but I did not get which is the true. However these 2 lines are keyword to also docs.ros is very usefull.
https://docs.ros.org/en/crystal/Contr...