-
Notifications
You must be signed in to change notification settings - Fork 604
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
Add Windows Compatibility Fixes for vision_opencv Build #538
base: humble
Are you sure you want to change the base?
Add Windows Compatibility Fixes for vision_opencv Build #538
Conversation
adding code based on ros-perception#401
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening this PR! Sorry it took me a while to get back - please check the feedback.
@@ -90,3 +92,7 @@ install(TARGETS ${PROJECT_NAME} | |||
ament_package( | |||
CONFIG_EXTRAS "cmake/cv_bridge-extras.cmake.in" | |||
) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this to line 41 in src/CMakeLists.txt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my tests I can only move after line 64. That works?
@@ -12,6 +12,8 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | |||
add_compile_options(-Wall -Wextra) | |||
endif() | |||
|
|||
add_compile_options(-DHAVE_SNPRINTF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is to treat the following warning:
warning C4996: '_vsnprintf': This function or variable may be unsafe. Consider using _vsnprintf_s instead.
Could you please replace the vnsprintf calls with vsnprintf_s instead of adding this compile option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error that I trying to solve was that:
C:/boost/boost/assert/source_location.hpp(95,9): error C2039: '_snprintf': is not a member of 'std' (compiling source file <ANONYMIZED_PATH>/src/vision_opencv/cv_bridge/src/module_opencv3.cpp) [<ANONYMIZED_PATH>/build/cv_bridge/src/cv_bridge_boost.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\string(24): message: see declaration of 'std' (compiling source file <ANONYMIZED_PATH>/src/vision_opencv/cv_bridge/src/module_opencv3.cpp) [<ANONYMIZED_PATH>/build/cv_bridge/src/cv_bridge_boost.vcxproj]
C:/boost/boost/assert/source_location.hpp(95,9): error C2039: '_snprintf': is not a member of 'std' (compiling source file <ANONYMIZED_PATH>/src/vision_opencv/cv_bridge/src/module.cpp) [<ANONYMIZED_PATH>/build/cv_bridge/src/cv_bridge_boost.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\string(24): message: see declaration of 'std' (compiling source file <ANONYMIZED_PATH>/src/vision_opencv/cv_bridge/src/module.cpp) [<ANONYMIZED_PATH>/build/cv_bridge/src/cv_bridge_boost.vcxproj]
C:/boost/boost/assert/source_location.hpp(102,13): error C2039: '_snprintf': is not a member of 'std' (compiling source file <ANONYMIZED_PATH>/src/vision_opencv/cv_bridge/src/module_opencv3.cpp) [<ANONYMIZED_PATH>/build/cv_bridge/src/cv_bridge_boost.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\string(24): message: see declaration of 'std' (compiling source file <ANONYMIZED_PATH>/src/vision_opencv/cv_bridge/src/module_opencv3.cpp) [<ANONYMIZED_PATH>/build/cv_bridge/src/cv_bridge_boost.vcxproj]
C:/boost/boost/assert/source_location.hpp(102,13): error C2039: '_snprintf': is not a member of 'std' (compiling source file <ANONYMIZED_PATH>/src/vision_opencv/cv_bridge/src/module.cpp) [<ANONYMIZED_PATH>/build/cv_bridge/src/cv_bridge_boost.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\string(24): message: see declaration of 'std' (compiling source file <ANONYMIZED_PATH>/src/vision_opencv/cv_bridge/src/module.cpp) [<ANONYMIZED_PATH>/build/cv_bridge/src/cv_bridge_boost.vcxproj]
I can only solve this using -DHAVE_SNPRINTF
Summary
This PR adds compatibility improvements to enable successful building of
vision_opencv
on Windows by introducing additional compiler options.Changes Made
Added Compiler Definitions for Windows Compatibility:
-DHAVE_SNPRINTF
toadd_compile_options
to ensure that thesnprintf
function is available during compilation. This is a common requirement when building cross-platform code on Windows.Boost Python Library Static Linking on Windows:
target_compile_definitions
was updated with-DBOOST_PYTHON_STATIC_LIB
. This option helps to statically link the Boost Python library, which is necessary for compatibility on Windows.Rationale
These changes are specifically intended as a workaround to address issues encountered when building
vision_opencv
on Windows. By adding thesnprintf
definition and setting Boost Python for static linking, this PR aims to resolve common build issues related to cross-platform support.Additional Notes
Resolves: #401