Boost は, C++ のライブラリ.
Windows で,Boost 最新版をソースコードからビルドして,インストールする手順を説明する.ビルドには,Build Tools for Visual Studio 2022(ビルドツール for Visual Studio 2022)を使用する.
【目次】
【関連する外部ページ】
Boost の利用条件などは、利用者が確認すること。次のWeb ページを活用してください
Windows での Visual Studio Community 2022 のインストール: 別ページ »で説明
Visual Studio Community 2022 に, Build Tools for Visual Studio 2022の機能が含まれている.
Windows での Build Tools for Visual Studio 2022 (ビルドツール for Visual Studio 2022) のインストール: 別ページ »で説明
【関連する外部ページ】
Git のページ https://git-scm.com/ からダウンロードしてインストール:
前もって,Boost をインストールするディレクトリを決めておく
このページでは,c:\boost 下にインストールするものとして説明する.
c:\boost 下にインストールするものとして説明する.
Windows では,コマンドプロン プトを管理者として実行し, 次のコマンドを実行する.
cd c:\ rmdir /s /q boost git clone --recursive https://github.com/boostorg/boost cd boost .\bootstrap.bat .\b2.exe --prefix=build --build-type=complete toolset=msvc link=static,shared address-model=64 install
エラーメッセージが出ていないこと。
次のコマンドで確認する.ここで確認したことは,のちほど,使用する.
dir "c:\boost\build\include"
Visual Studio の x64 Native Tools コマンドプロンプトを管理者として実行する. 次のコマンドを実行する.
「boost-1_81」のところは,先ほど確認したインクルードディレクトリに一致させること.
cl /EHsc /I "c:\boost\build\include\boost-1_81" ^ "c:\boost\libs\geometry\example\01_point_example.cpp" .\01_point_example.exe del 01_point_example.exe
コマンドプロンプトを管理者として実行: 別ページ »で説明
call powershell -command "[System.Environment]::SetEnvironmentVariable(\"BOOST_DIR\", \"c:\boost\build\", \"Machine\")"
コマンドプロンプトを管理者として実行: 別ページ »で説明
call powershell -command "[System.Environment]::SetEnvironmentVariable(\"BOOST_ROOT\", \"c:\boost\build\", \"Machine\")"
作者に感謝します.
#include <stdio.h> #include<boost/lambda/lambda.hpp> #include<iostream> #include<iterator> #include<algorithm> int main() { using namespace boost::lambda; typedef std::istream_iterator<int> in; std::for_each( in(std::cin), in(), std::cout << (_1 * 3) << " "); }
cl /EHsc /I "c:\boost\build\include\boost-1_81" hoge.cpp echo 1 2 3 | .\hoge.exe