Skip to content

Instantly share code, notes, and snippets.

@oxycoder
Created June 28, 2019 06:58
Show Gist options
  • Save oxycoder/98864df68f7a879066c51c181a492fe2 to your computer and use it in GitHub Desktop.
Save oxycoder/98864df68f7a879066c51c181a492fe2 to your computer and use it in GitHub Desktop.
Build Boost 1.70.0 with Clang 8 / LLVM on windows

Requirement: Visual stuio 2019 LLVM : http://releases.llvm.org/8.0.0/LLVM-8.0.0-win64.exe

Step 1: Install Visual studio 2019

Step 2: Install LLVM (remember to check add llvm to system enviroment path)

Step 3: Check if clang is work: Open cmd, type:

clang --version
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\LLVM\bin

Step 4: Download boost library source code: https://dl.bintray.com/boostorg/release/1.70.0/source/

step 4: cd C:\boost_source_dir

step 5: Edit project-config.jam file in boost source dir

# Boost.Build Configuration 
# Automatically generated by bootstrap.bat 

import option ; 

using clang
:
:
:
cxxstd=17
<ranlib>"C:/LLVM/bin/llvm-ranlib.exe"
<archiver>"C:/LLVM/bin/llvm-ar.exe" 
<cxxflags>-D_CRT_SECURE_NO_WARNINGS
<cxxflags>-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING
 ; 

option.set keep-going : false ; 

step 6: Compile boost

  bootstrap
  b2 cxxstd=17 link=static address-model=64 --layout=tagged --build-type=complete --architecture=x64 --threading=multi toolset=clang --without-python --withtout-icu variant=release

It's will give a lot of warning for deprecated functions, but it works.

@ink-splatters
Copy link

Fuck it's still the only way to make it work with clang on Windows in 2020! You are God man!

@fengzhuo17
Copy link

我尝试用--with-python这个参数编译

使用的clang情况为:
clang version 11.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin

.jam文件中内容:

Boost.Build Configuration

Automatically generated by bootstrap.bat

import option ;

using clang
:
:
:
cxxstd=17
"C:/LLVM/bin/llvm-ranlib.exe"
"C:/LLVM/bin/llvm-ar.exe"
-D_CRT_SECURE_NO_WARNINGS
-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING
;

option.set keep-going : false ;

using python : 3.8 : (home)\Miniconda3\envs\py38 : (home)\Miniconda3\envs\py38\include : (home)\Miniconda3\envs\py38\libs ;

执行b2的指令为:
b2 install link=static runtime-link=shared --with-python

最终未能生成库文件

@smaudet
Copy link

smaudet commented Oct 30, 2023

Using clang version 16.0.0 against boost 1.8.3:

import option ;

using clang
:
:
:
cxxstd=17
"D:/llvm16.0.4_32/LLVM/bin/llvm-ranlib.exe"
"D:/llvm16.0.4_32/LLVM/bin/llvm-ar.exe"
-D_CRT_SECURE_NO_WARNINGS
-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING
-fms-runtime-lib=static_dbg
;

option.set keep-going : false ;

b2 cxxstd=17 link=static address-model=64 --layout=tagged --build-type=complete --architecture=x64 threading=multi toolset=clang --without-python variant=release

Appeared to work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment