conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
948 stars 1.73k forks source link

[package] boost/1.82.0: bcrypt system dependency missing in header only #23198

Open fschoenm opened 6 months ago

fschoenm commented 6 months ago

Description

We're using boost in header only mode with these options:

        "boost/*:header_only": True,
        "boost/*:error_code_header_only": True,

However, when using e.g. the Uuid library, bcrypt is required on Windows. The package doesn't specify this system dependency.

Package and Environment Details

Conan profile

Host profile: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=20 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows [conf] tools.cmake.cmaketoolchain:generator=Ninja tools.env.virtualenv:powershell=True

Build profile: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=20 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows [conf] tools.cmake.cmaketoolchain:generator=Ninja tools.env.virtualenv:powershell=True

Steps to reproduce

conan install . -s build_type=Debug

Logs

Click to expand log ``` ... Basic.lib(Path.cpp.obj) : error LNK2019: unresolved external symbol BCryptCloseAlgorithmProvider referenced in function "private: void __cdecl boost::uuids::detail::random_provider_base::destroy(void)" (?destroy@random_provider_base@detail@uuids@boost@@AEAAXXZ) Basic.lib(Path.cpp.obj) : error LNK2019: unresolved external symbol BCryptGenRandom referenced in function "public: void __cdecl boost::uuids::detail::random_provider_base::get_random_bytes(void *,unsigned __int64)" (?get_random_bytes@random_provider_base@detail@uuids@boost@@QEAAXPEAX_K@Z) Basic.lib(Path.cpp.obj) : error LNK2019: unresolved external symbol BCryptOpenAlgorithmProvider referenced in function "public: __cdecl boost::uuids::detail::random_provider_base::random_provider_base(void)" (??0random_provider_base@detail@uuids@boost@@QEAA@XZ) ```
AbrilRBS commented 6 months ago

Do you plan on submitting the fix? :)

fschoenm commented 6 months ago

Unfortunately, I don't even know why this dependency is missing. Aren't header-only packages allowed to have additional dependencies? Because it seems like the botan package was explicitly designed to be this way.

Nekto89 commented 6 months ago

Unfortunately, I don't even know why this dependency is missing. Aren't header-only packages allowed to have additional dependencies? Because it seems like the botan package was explicitly designed to be this way.

https://github.com/conan-io/conan-center-index/issues/21658#issuecomment-1846022248

fschoenm commented 6 months ago

@Nekto89 So what is the solution? Fact is, the Uuid library doesn't work without the bcrypt dependency on Windows and still is considered a header-only library.

Nekto89 commented 6 months ago

@Nekto89 So what is the solution? Fact is, the Uuid library doesn't work without the bcrypt dependency on Windows and still is considered a header-only library.

One of solutions is to use boost/*:magic_autolink=True Another solution: add linking to bcrypt to your build system. For example, target_link_libraries(my_app PRIVATE bcrypt) Another solution: link to bcrypt directly in C++ code where you are using headers that require bcrypt. Example:

#ifdef yourwindowsdefine
// Boost doesn't automatically link with it
#pragma comment(lib, "Bcrypt.lib")
#endif
fschoenm commented 6 months ago

@Nekto89 I think I don't really understand what magic_autolink=True does. Is it using boost headers to automatically link against system libs? That might be a solution but then I don't understand why it isn't the default.

Options 2 and 3 are IMO not very good solutions because why do I have to know additional boost dependencies if I'm just using the boost package? That's the job of the dependency management.

Nekto89 commented 6 months ago

@Nekto89 I think I don't really understand what magic_autolink=True does. Is it using boost headers to automatically link against system libs? That might be a solution but then I don't understand why it isn't the default.

Options 2 and 3 are IMO not very good solutions because why do I have to know additional boost dependencies if I'm just using the boost package? That's the job of the dependency management.

from documentation of Boost:

BOOST_ALL_NO_LIB | Tells the config system not to automatically select which libraries to link against. Normally if a compiler supports #pragma lib, then the correct library build variant will be automatically selected and linked against, simply by the act of including one of that library's headers. This macro turns that feature off.

You can also try using define "BOOST_UUID_FORCE_AUTO_LINK" if you don't want to enable auto-link for whole Boost but I don't know whether it will work

Boost.uuid has bcrypt in auto-link part https://github.com/boostorg/uuid/blob/2bc0c8e71677f387afdc09bc4f8d609d2c74e80e/include/boost/uuid/detail/random_provider_bcrypt.ipp#L20