Open ras0219-msft opened 5 years ago
Hi I am running into this issue trying to build ome-files as a dll on Windows using a vcpkg environment. Is there a workaround for this?
FYI, they have the following definition in CMakeLists.txt
add_definitions(-DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB)
I had the same issue with vcpkg
messing up boost's linking.
I fixed it by defining BOOST_UUID_FORCE_AUTO_LINK
by using the compiler options.
Hi sagarjha, could you explain how you did that? I saw the suggestion to do so, but no explanation of how.
Sure. Let me first explain my rationale. If you look at https://github.com/boostorg/uuid/blob/develop/include/boost/uuid/detail/random_provider_bcrypt.ipp#L20, you'll find:
#if defined(BOOST_UUID_FORCE_AUTO_LINK) || (!defined(BOOST_ALL_NO_LIB) && !defined(BOOST_UUID_RANDOM_PROVIDER_NO_LIB))
# define BOOST_LIB_NAME "bcrypt"
# if defined(BOOST_AUTO_LINK_NOMANGLE)
# include <boost/config/auto_link.hpp>
# else
# define BOOST_AUTO_LINK_NOMANGLE
# include <boost/config/auto_link.hpp>
# undef BOOST_AUTO_LINK_NOMANGLE
# endif
which defines the condition under which boost
will link against the bcrypt library. Since BOOST_ALL_NO_LIB
is set by vcpkg
, I just need to set BOOST_UUID_FORCE_AUTO_LINK
. There are multiple ways to do that. I am using CMake, so I set the compiler flag to define this variable. My CMakeLists.txt contains:
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_WIN32_WINNT=0x0601 -DBOOST_UUID_FORCE_AUTO_LINK")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_WIN32_WINNT=0x0601 -DBOOST_UUID_FORCE_AUTO_LINK")
If you're using CMake
, you can add -DBOOST_UUID_FORCE_AUTO_LINK
to your options.
There is another way to do this, which I was using before: I link my executable against both boost libraries and bcrypt. So something like:
find_package(Boost REQUIRED COMPONENTS system serialization)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(my_lib ${Boost_SYSTEM_LIBRARY}
${Boost_SERIALIZATION_LIBRARY} bcrypt...)
This worked but the problem was that windows complains about having to search the bcrypt
library which shows up as a warning when you run cmake.
I'm using Visual Studio 2019 and was able to resolve these symbols by adding bcrypt.lib to the linker input.
I'm using Visual Studio 2019 and was able to resolve these symbols by adding bcrypt.lib to the linker input.
I'm having similar issues with cpprestsdk
. People mention manual linking of system libs as "solving the problem", but the information is available in the package itself (eg. when looking in the cmake export target file) so there is no reason one should have to do this step.
But is the ("true") solution still to link additional system libraries & specify defines manually when using vcpkg in Visual Studio?
Edit Ok nvm, found that it's on the todo.
I'm using Visual Studio 2019 and was able to resolve these symbols by adding bcrypt.lib to the linker input.
I'm having similar issues with
cpprestsdk
. People mention manual linking of system libs as "solving the problem", but the information is available in the package itself (eg. when looking in the cmake export target file) so there is no reason one should have to do this step. But is the ("true") solution still to link additional system libraries & specify defines manually when using vcpkg in Visual Studio?Edit Ok nvm, found that it's on the todo.
That's just a workaround, not a fix.
From https://github.com/boostorg/uuid/issues/68