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

cxxstd not working when building using b2 under Windows #7730

Open
alervd opened this issue Aug 28, 2024 · 4 comments
Open

cxxstd not working when building using b2 under Windows #7730

alervd opened this issue Aug 28, 2024 · 4 comments

Comments

@alervd
Copy link

alervd commented Aug 28, 2024

Please provide the following information

libtorrent version (or branch): 1.2.19.

platform/architecture: Windows 10.

compiler and compiler version: Microsoft Visual C++ 2022.

please describe what symptom you see, what you would expect to see instead and
how to reproduce it.

  1. Download prebuild boost 1.85.0 binaries from the official site.
  2. Build b2 as stated in the docs (https://www.libtorrent.org/building.html).
  3. Try to build boost with b2 cxxstd=20.

Result:

compile-c-c++ bin\msvc-14.3\debug\crypto-openssl\cxxstd-20-iso\deprecated-functions-off\link-static\logging-off\threading-multi\src\block_cache.obj
block_cache.cpp
D:\Work\Source\libtorrent-build\openssl3\libtorrent-x86\include\libtorrent/units.hpp(168): error C2039: 'result_type': is not a member of 'std::hash<int>'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\system_error(410): note: see declaration of 'std::hash<int>'

I've found that when it builds libtorrent source files, __cplusplus is set to 199711L (however as you can see above it's using c++20 somewhere else so we get a conflict).

It works with cxxstd=11 (and I think 14 too), because the "culprit" was not deprecated in this standards yet.

@alervd
Copy link
Author

alervd commented Aug 28, 2024

It seems this is caused by this: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170.
Is there a way to pass this compiler switch to b2?

@alervd
Copy link
Author

alervd commented Aug 28, 2024

So, it's required to pass cxxflags="\"/Zc:__cplusplus\"" for the build to work properly under MSVC compiler. Please update docs / fix build system so one do not have to specify it manually.

So, the working command would be something like b2.exe cxxstd=20 cxxflags="\"/Zc:__cplusplus\"".

@arvidn
Copy link
Owner

arvidn commented Sep 30, 2024

I believe this is related #7545

@arvidn
Copy link
Owner

arvidn commented Oct 1, 2024

I believe the RC_2_0 branch builds as C++20 (but with some warnings)

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