Umberto Fontana
Umberto Fontana

Reputation: 1

Error LNK2019 link error catkin_make windows

I am trying to compile a ROS package in Windows. I follow the procedure to set the ROS environment described here http://wiki.ros.org/Installation/Windows . I want to compile a ROS package tested and working on ROS in Linux. This package has to use a static library (.lib) compiled with Visual Studio 2019. I add the dependency in My CMakeList.txt as follow:

add_library(name STATIC IMPORTED)
set_property(TARGET name PROPERTY IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/api/lib/name_of_lib.lib)
target_link_library(node_name 
                    PUBLIC 
                    ${catkin_LIBRARIES} 
                    name)

After running the command catkin_make from the Visual Studio shell i received the error LNK2019 for a function defined in the .lib file. The error is: “CMakeFiles.....\manifest.res failed (exit code 1120) with the following output: communication_handler.cpp.obj:error LNK2019: unresolved external symbol ..... “

The .lib file Was generated on the same computer With the same VisualStudio version of the developer command prompt. Can anyone help me?

Upvotes: 0

Views: 316

Answers (1)

Tully
Tully

Reputation: 540

For Windows build it's important to export symbols.

There's documentation of how to do this for ROS 2 here:

https://docs.ros.org/en/rolling/The-ROS2-Project/Contributing/Windows-Tips-and-Tricks.html#symbol-visibility

For errors like error LNK2019: unresolved external symbol if you've done most of the above it can mean that you have failed to add the <PACKAGENAME>_PUBLIC export like this https://github.com/ros2/geometry2/pull/646/commits/10dc05c53406455619dd5f2dfd668dcab5cac881

   */
  TF2_PUBLIC // <<--- Missing
  geometry_msgs::msg::VelocityStamped lookupVelocity(

Upvotes: 0

Related Questions