Rosidl unresolved external symbol issue when creating a publisher using the custom msg.
I am able to build rosidl custom msgs using ROS2 crystal (Windows).
But when I am trying to build an executable using even default rosidl custom msgs (Say String.msg), I am getting unresolved external symbols issue.
I have added all the libs generated inside rosidl build folder. If anybody can help, what mistake I am doing, that would be helpful. Thanks for your time in advance. Here is the error.
error LNK2001: unresolved external symbol "struct rosidl_message_type_support_t const * __cdecl rosidl_typesupport_cpp::get_message_type_support_handle<struct rosidl_generator_cpp::msg::String_<class std::allocator<void> > >(void)" (??$get_message_type_support_handle@U?$String_@V?$allocator@X@std@@@msg@rosidl_generator_cpp@@@rosidl_typesupport_cpp@@YAPEBUrosidl_message_type_support_t@@XZ)
Without more information it's hard to provide assistance, please consider providing your CMakeLists.txt.
If I had to guess, you may be missing a
ament_target_dependencies
call in your CMake. You can see https://github.com/ros2/examples/blob... for a simple example of how to use messages in an executableI am not using CMakeList to build the exe. I have created my own Visual Studio Project where I am able to build executable with Std_Msgs but facing this issue while building custom msgs. I have added all the necessary rosidl libs in visual studio properties. But still getting the above mentioned error.
What is the difference between the project building
std_msgs
and your custom messages? Are the included libraries exactly the same? Do your custom messages depend on other message packages (like std_msgs)? If so you'll need to include the libraries of the dependencies as well.Actually, What I am doing is , I am trying to create a publisher like this, and I am facing the issue :
auto publisher = node->create_publisher<rosidl_generator_cpp::msg::string>("CM_TO_DLL");
Same like this for Std_msgs , publisher is working , for example :
auto publisher = node->create_publisher<std_msgs::msg::float32>("CM_TO_DLL");
I added all the necessary libs, as per my understanding, which were getting generated after building rosidl package using colcon build.
By the way, Thanks for investing your time in trying to understand my issue.