ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Windows DLL Dependencies/External non-ROS?

asked 2021-01-07 11:07:17 -0500

qTHqq gravatar image

I'm developing a robotics control library that will primarily be used in a cross-platform desktop app. We're developing on Windows mostly, and I build my library as a DLL from a Visual Studio project with manually managed dependencies. I'd like to do prototyping and simulation experiments with my library using ROS, and I'd like my ROS nodes to depend on my DLL.

I've got a working Melodic installation on my Windows dev machine via the Microsoft IoT project https://ms-iot.github.io/ROSOnWindows/ and I can build C++ nodes. Now I'm curious if there are suggested or emerging practices or a recipe for where to actually put custom system-dependency DLLs for ROS on Windows.

It feels like for my use case, it doesn't really matter, and I should pick a rando install location and refer to it in CMake in each of my custom ROS packages by manually setting mylib_INCLUDE_DIRS and mylib_LIBRARIES or something like that. I won't be distributing this beyond my team.

But if there's kind of a suggested location or recipe that will make it easier to share across multiple machines, especially something that would make it easier to manage cross-platform ROS work on Windows and Linux, I'd love some input.

I get the impression that "where do you put a DLL?" is not really a question with an answer, and it's someone else's problem for me outside the ROS context.

edit retag flag offensive close merge delete

Comments

Update: I think I'm going to try to package my DLL and header as a CMake Config-file package https://cmake.org/cmake/help/v3.18/gu... if that changes any advice.

qTHqq gravatar image qTHqq  ( 2021-01-07 12:29:14 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2021-01-07 18:00:23 -0500

qTHqq gravatar image

updated 2021-01-07 18:01:33 -0500

I laid out my library in C:\usr\x64 (kind of mirroring ROS on Windows hardcoding to C:\opt\ros\melodic\x64) like this:

C:\USR
└───x64
    ├───include
    │   └───mylib-0.2-rc2
    │       └───mylib
    │               LibName.h
    │
    └───lib
        ├───cmake
        │   └───mylib-0.2-rc2
        │           mylib-config-version.cmake
        │           mylib-config.cmake
        │
        └───mylib-0.2-rc2
                LibName.dll
                LibName.lib

with mylib-config.cmake contents

get_filename_component(PREFIX ${CMAKE_CURRENT_LIST_DIR}/../../.. ABSOLUTE)
set(mylib_INCLUDE_DIRS ${PREFIX}/include/mylib-0.2-rc2)
set(mylib_LIBRARIES ${PREFIX}/lib/mylib-0.2-rc2/LibName.lib)

Pending a better, ROS-correct way to set it, I made a user environment variable CMAKE_PREFIX_PATH with C:\usr\x64. ROS setup.bat files then prepend the ROS paths to that.

Now catkin_make can find my library using find_package(mylib REQUIRED) in my ROS package's CMakeLists.txt.

I'm still having some include issues, so I'm not going to close this question just yet.

[ 39%] Building CXX object mylib_gazebo/CMakeFiles/mylib_hello_node.dir/src/mylib_hello_node.cpp.obj
mylib_hello_node.cpp
C:\usr\x64\include\mylib-0.2-rc2\mylib/LibName.h(5): fatal error C1083: Cannot open include file: 'Eigen/Core': No such file or directory
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1427~1.291\bin\Hostx64\x64\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
Invoking "nmake" failed

But it's some progress, and I feel like it's a reasonable layout. Is there a correct place to prepend to CMAKE_PREFIX_PATH that's recommended for a ROS workspace?

edit flag offensive delete link more

Comments

Fixed these errors by addressing:

I had to copy my DLL to the catkin_ws\devel\lib\mylib_gazebo directory along with mylib_hello_node.exe. I expect there's some way to use Boost (which I use for DLL loading) to automatically find the installed DLL. However, I think this completes a recipe for using a DLL from Visual Studio in ROS on Windows.

qTHqq gravatar image qTHqq  ( 2021-01-07 22:10:08 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2021-01-07 11:07:17 -0500

Seen: 479 times

Last updated: Jan 07 '21