0

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?

  • It is difficult to see what might be going wrong here. Can you provide a more concrete example, using the **actual** path to the library, and *showing* the error message instead of describing it? You may have better results if `path/to/.lib` is a *full* path. – Kevin Jun 28 '20 at 12:25
  • ok thanks, path/to/.lib in the CMakeList.txt file is replaced with ${PROJECT_SOURCE_DIR}/api/lib/name_of_lib.lib. The error in the Visual studio shell starts with “CMakeFiles\.....\manifest.res failed (exit code 1120) with the following output: communication_handler.cpp.obj:error LNK2019: unresolved external symbol ..... “ – Umberto Fontana Jun 28 '20 at 12:56
  • Thanks, please add this info with the **complete** error message to your question post, the comment section is not meant for lengthy and meaningful content essential to the question. – Kevin Jun 28 '20 at 13:40
  • Please try to use command `target_link_libraries(node_name PUBLIC ${catkin_LIBRARIES} PUBLIC name)` instead. – Michael Xu Jul 23 '20 at 08:12

0 Answers0