jrl-umi3218 / RBDyn

RBDyn provides a set of classes and functions to model the dynamics of rigid body systems.
BSD 2-Clause "Simplified" License
157 stars 47 forks source link

Windows failed to compile if BUILD_SHARED_LIBS=OFF #106

Closed pzhu-flexiv closed 9 months ago

pzhu-flexiv commented 10 months ago

On Windows (I'm using MSVC v143 if this information is relevant), if set the cmake option BUILD_SHARED_LIBS to OFF, then the compilation would fail. The errors look like this: image

After some debugging, I found the root cause is this macro block in RBDyn image and this macro block in RBDynParsers image are both NOT properly activated even if BUILD_SHARED_LIBS=OFF, because the macro RBDYN_STATIC and RBDYN_PARSERS_STATIC are never defined in cmake. This caused the __declspec(dllimport) Windows shared library directive to be appended in the compiled static library RBDyn.lib and RBDynParsers.lib, which caused the linker errors.

Making the following changes solved the issue, please review and PR the fix, thanks. image image

gergondet commented 9 months ago

Hi @pzhu-flexiv

I think you are using an older version of RBDyn because this was already reported and fixed in https://github.com/jrl-umi3218/RBDyn/commit/22c5dde7b48b0037e106e7901b0611ccd506ae5e