Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix osx and win32 builds #83

Merged
merged 8 commits into from
Oct 23, 2023
Merged

Fix osx and win32 builds #83

merged 8 commits into from
Oct 23, 2023

Conversation

Tobias-Fischer
Copy link

On osx, one should not link against the uuid library - it's in the system's path already.

On win32, there are several fixes needed: CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS so a DLL is created, add_definitions(-DNOMINMAX) to avoid namespace clashes for min and max, and the uuid library there is simply called Rpcrt4.lib.

@traversaro
Copy link

traversaro commented Mar 26, 2022

Hi @mjcarroll, let us know if there is any we (as RoboStack, from which this patch originates: osx and win) can do to help getting this PR merged, thanks!

Downstream issue: RoboStack/ros-galactic#31 .

bondcpp/CMakeLists.txt Outdated Show resolved Hide resolved
# we have to find the absolute path to uuid as target_link_directories is not available before cmake 3.13
find_library(uuid_ABS_PATH ${UUID_LIBRARIES} PATHS ${UUID_LIBRARY_DIRS})
elseif(WIN32)
set(uuid_ABS_PATH Rpcrt4.lib)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really make it work on Windows? Where does Rpcrt4.lib come from?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkg_check_modules(UUID REQUIRED uuid)
# we have to find the absolute path to uuid as target_link_directories is not available before cmake 3.13
find_library(uuid_ABS_PATH ${UUID_LIBRARIES} PATHS ${UUID_LIBRARY_DIRS})
if(UNIX AND NOT APPLE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens on macOS? If we are never finding the uuid library, how does it build/link against it?

Copy link

@traversaro traversaro Mar 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On macOS libuuid header and symbols are provided by the OS SDK/libc, so there is no need to provide additonal header directories or library to link, see gazebosim/gz-cmake#128 and gazebosim/gz-cmake#127 for a similar change on Ignition libraries or https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/uuid_generate.3.html for the macOS docs.

@mjcarroll
Copy link
Member

Howdy @traversaro , will take a look at this once I can get #87 landed to get a majority of the "cleanups" in.

@traversaro
Copy link

Howdy @traversaro , will take a look at this once I can get #87 landed to get a majority of the "cleanups" in.

Great, thanks!

Copy link
Member

@mjcarroll mjcarroll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is mostly good, question on definitions, and I may have introduced a linting error on the merge.

bondcpp/CMakeLists.txt Outdated Show resolved Hide resolved
@mjcarroll
Copy link
Member

@Tobias-Fischer friendly ping

Copy link

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me with green CI.

@iggyrrieta
Copy link

Hi! Thanks for publishing this!

I just cloned and failed building with following specs:

  • ROS 2 Humble
  • Windows SDK version 10.0.22621.0 to target Windows 10.0.19045
  • C compiler identification is MSVC 19.29.30152.0
  • CXX compiler identification is MSVC 19.29.30152.0

Command I tried:

colcon build --symlink-install --merge-install --packages-select bond smclib bondcpp --event-handlers console_direct+

Output:

  • bond
  • smclib
  • bondcpp

Summary: 2 packages finished [53.6s]
1 package failed: bondcpp

@clalancette
Copy link

After trying this locally, we definitely need a fix in rclcpp_lifecycle for this to work; see ros2/rclcpp#2331 . After that fix, there are some additional warnings in here:

C:/bond_ws/install/include/bond\bond/msg/detail/constants__struct.hpp(66,1): warning C4305: 'initializing': truncation from 'double' to 'const float' (compiling source file C:\bond_ws\src\bond_core\bondcpp\src\BondSM_sm.cpp) [C:\bond_ws\build\bondcpp\bondcpp.vcxproj]
C:/bond_ws/install/include/bond\bond/msg/detail/constants__builder.hpp(34): message : see reference to class template instantiation 'bond::msg::Constants_<std::allocator<void>>' being compiled (compiling source file C:\bond_ws\src\bond_core\bondcpp\src\BondSM_sm.cpp) [C:\bond_ws\build\bondcpp\bondcpp.vcxproj]
C:/bond_ws/install/include/bond\bond/msg/detail/constants__struct.hpp(66,1): warning C4305: 'initializing': truncation from 'double' to 'const float' (compiling source file C:\bond_ws\src\bond_core\bondcpp\src\bond.cpp) [C:\bond_ws\build\bondcpp\bondcpp.vcxproj]
C:/bond_ws/install/include/bond\bond/msg/detail/constants__builder.hpp(34): message : see reference to class template instantiation 'bond::msg::Constants_<std::allocator<void>>' being compiled (compiling source file C:\bond_ws\src\bond_core\bondcpp\src\bond.cpp) [C:\bond_ws\build\bondcpp\bondcpp.vcxproj]
C:\bond_ws\install\include\smclib/statemap.hpp(89,17): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. (compiling source file C:\bond_ws\src\bond_core\bondcpp\src\BondSM_sm.cpp) [C:\bond_ws\build\bondcpp\bondcpp.vcxproj]
C:\bond_ws\install\include\smclib/statemap.hpp(89,17): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. (compiling source file C:\bond_ws\src\bond_core\bondcpp\src\bond.cpp) [C:\bond_ws\build\bondcpp\bondcpp.vcxproj]
C:\bond_ws\src\bond_core\bondcpp\src\bond.cpp(561,53): warning C4244: '=': conversion from 'double' to 'bond::msg::Status_<std::allocator<void>>::_heartbeat_timeout_type', possible loss of data [C:\bond_ws\build\bondcpp\bondcpp.vcxproj]
C:\bond_ws\src\bond_core\bondcpp\src\bond.cpp(562,51): warning C4244: '=': conversion from 'double' to 'bond::msg::Status_<std::allocator<void>>::_heartbeat_period_type', possible loss of data [C:\bond_ws\build\bondcpp\bondcpp.vcxproj]

Once those are all fixed, we can consider merging this.

This is to avoid a warning on Windows.  It is safe to do
since the heartbeat timeout or period aren't expected to
be outside the range a float can represent.

Signed-off-by: Chris Lalancette <[email protected]>
@clalancette
Copy link

OK, we also need ros2/rosidl#772 . And I also just pushed some additional fixes.

With all of that in place, the last bit here is to fix the warnings about using strncpy. Once that is fixed, I think this will be ready.

Also make it allocate less memory in general.

Signed-off-by: Chris Lalancette <[email protected]>
@clalancette clalancette merged commit 330a2a7 into ros:ros2 Oct 23, 2023
4 checks passed
@Tobias-Fischer Tobias-Fischer deleted the patch-8 branch October 23, 2023 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants