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

PSA: Some boost libraries didn't compile #3

Closed
s9w opened this issue Jun 23, 2021 · 11 comments
Closed

PSA: Some boost libraries didn't compile #3

s9w opened this issue Jun 23, 2021 · 11 comments

Comments

@s9w
Copy link
Owner

s9w commented Jun 23, 2021

#include <boost/asio.hpp>

Failed with: Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. [...]

#include <boost/json/src.hpp>

complained about a missing link file (LINK : fatal error LNK1104: cannot open file 'libboost_container-vc142-mt-gd-x64-1_76.lib') although according to the manual this should be header-only.

And with beast I have no idea what headers are usually used?

If any of those libs are of interests, I may look into it again.

@s9w s9w mentioned this issue Jun 23, 2021
@s9w s9w pinned this issue Jun 23, 2021
@vinniefalco
Copy link

vinniefalco commented Jun 23, 2021

Boost.Asio and Boost.Beast are very heavy to compile, they are not representative of libraries that are in any way "fast." In order to use these libraries effectively (i.e. for them to have reasonable compilation times) users are required to be very mindful and meticulous about the physical structure of their declarations which use those library components. Type-erasure is must here, as exposing asio.hpp or beast.hpp in commonly included public headers will incur large compilation costs.

The John Lakos book "Large-Scale C++ Software Design" is helpful in this context.

@s9w
Copy link
Owner Author

s9w commented Jun 23, 2021

Thanks @vinniefalco for the insights! They seem not a good fit for this overview then, and would probably dwarf the rest either way.

@vinniefalco
Copy link

and would probably dwarf the rest either way.

Yeah, you could say that :)

@vinniefalco
Copy link

although according to the manual this should be header-only

Yes it should work, but depending on how your build scripts are set up it might not. When including src.hpp (i.e. "header-only") you want Boost's "autolink" feature to be off.

How do your build scripts include Boost.JSON? Are you using CMake? B2?

@s9w
Copy link
Owner Author

s9w commented Jun 23, 2021

I go in raw, i.e. call cl.exe directly. No build system

@vinniefalco
Copy link

vinniefalco commented Jun 23, 2021

RAW!!! heh... anyway, try defining BOOST_CONTAINER_NO_LIB (this disables auto-linking for Boost.Container).

@s9w
Copy link
Owner Author

s9w commented Jun 23, 2021

Hm that works "a bit": Works for a single TU. But when I interpreted the documentation correctly, the idea is to have one TU with

#include <boost/json/src.hpp>

and all others with:

#include <boost/json.hpp>

But with a second TU, the LINK : fatal error LNK1104: cannot open file 'libboost_json-vc142-mt-gd-x64-1_76.lib'is back again

@vinniefalco
Copy link

hmm I guess you have to also define BOOST_JSON_NO_LIB (to prevent autolinking to Boost.JSON). I will open an issue so that the usage instructions make this clear.

@s9w
Copy link
Owner Author

s9w commented Jun 23, 2021

That works, thanks for your help. I'm going to have to rerun all times because the baseline changed with the single json/src.hpp. So boost.json will be up tomorrow or so.

@vinniefalco
Copy link

Cool! Yeah, just remember that we care about the time for including <boost/json.hpp>, not <boost/json/src.hpp>, since the src.hpp definitions are provided by the linked library (or the user's one TU they included it in).

@s9w
Copy link
Owner Author

s9w commented Jun 24, 2021

I added boost/json.hpp to the overview so I consider this done. Thanks for the support again.

@s9w s9w closed this as completed Jun 24, 2021
@s9w s9w unpinned this issue Jun 24, 2021
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

2 participants