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

Linking to bcrypt creates problems (i.e. for CMake users) #122

Closed
pdimov opened this issue Nov 2, 2021 · 9 comments
Closed

Linking to bcrypt creates problems (i.e. for CMake users) #122

pdimov opened this issue Nov 2, 2021 · 9 comments

Comments

@pdimov
Copy link
Member

pdimov commented Nov 2, 2021

As reported in boostorg/boost_install#54, using UUID from a CMake project requires one to manually link to bcrypt on Windows. That's because the CMake config files define BOOST_ALL_NO_LIB, which disables autolinking not just to Boost libraries (which is the intent), but to bcrypt.lib as well.

In addition, since UUID is a header-only library, it has no CMake target to which code could link in order to inherit the dependency to bcrypt.

If we're intending to keep linking to bcrypt, one option here is to create a dummy compiled library, whose only purpose would be to expose a Boost::uuid target in CMake, which would then link to bcrypt.

@Lastique
Copy link
Member

Lastique commented Nov 2, 2021

I'm not the maintainer, but linking with bcrypt is essential. The alternative is wincrypt, but it is deprecated and I don't think is universally available.

I also don't think introducing a dummy compiled library is an adequate solution, as this creates a bunch of other problems. For example, it affects packaging and downstream dependencies for no good reason.

IMHO, this should be solved entirely in CMake and headers. One option is stop defining BOOST_ALL_NO_LIB. Another is ignore it for linking non-Boost libraries.

@pdimov
Copy link
Member Author

pdimov commented Nov 2, 2021

Relying on autolink to hide the problem doesn't seem correct; it doesn't work for GCC. But assuming we don't care about GCC, we've had the discussion of whether BOOST_ALL_NO_LIB should apply to non-Boost libraries more than once now, without any results.

I wouldn't be in support of enabling autolink for Boost libraries when using the CMake config files; this causes nothing but trouble (even if it does help to hide errors occasionally.)

@Lastique
Copy link
Member

Lastique commented Nov 2, 2021

Yes, enabling auto-link is just a workaround, something we could consider for 1.78. The proper solution is to find a way to generate CMake config files for header-only libraries while keeping them header-only.

@Leon0402
Copy link

Leon0402 commented Jan 9, 2022

he proper solution is to find a way to generate CMake config files for header-only libraries while keeping them header-only

I would love to see this, so I can use Boost::uuid and others to correctly link all targets. In case of other libraries like Boost libraries, I also need to link other boost libraries explicitly like filesystem, which is confusing.

Should this maybe tracked in a separate issue? Perhaps in boost_install?

@jeking3
Copy link
Collaborator

jeking3 commented Jan 25, 2022

I'm guessing someone has a workaround for this, for now - it might be useful to share that to help others in the same situation.

@pdimov
Copy link
Member Author

pdimov commented Jan 25, 2022

I changed the CMake config files to only define the corresponding library-specific _NO_LIB macro instead of BOOST_ALL_NO_LIB, which takes care of this and similar issues on compilers that support autolinking. (boostorg/boost_install@258f786)

@jeking3
Copy link
Collaborator

jeking3 commented Feb 4, 2022

@pdimov is there anything that needs to be done here as a result of that?

@pdimov
Copy link
Member Author

pdimov commented Feb 4, 2022

I don't think we can do anything in practice, short of switching to a compiled library, which is unacceptable for many. So, closing.

@pdimov pdimov closed this as completed Feb 4, 2022
@jeking3
Copy link
Collaborator

jeking3 commented Feb 4, 2022

Thanks, worked hard to keep this header-only.

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

No branches or pull requests

4 participants