c_cpp:boost

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
c_cpp:boost [2020/08/27 03:08] – [Visual Studio へのインストール] ともやんc_cpp:boost [2021/07/05 02:02] (現在) ともやん
行 1: 行 1:
-<html> 
-  <style> 
-    #result pre, #mincode pre { 
-      overflow: hidden; 
-      font-size: 10px; 
-    } 
-    #result_long pre, #mincode_long pre  { 
-      height: 250px; 
-      overflow: scroll; 
-      overflow-x: hidden; 
-      font-size: 10px; 
-    } 
-    #mintbl table { 
-      font-size: 12px; 
-    } 
-    .dokuwiki .plugin_wrap table { 
-      width: auto; 
-    } 
-    #logo { 
-      background-color: white; 
-      padding: 10px; 
-      width: fit-content; 
-    } 
-    #logo p { 
-      margin: 0; 
-    } 
-  </style> 
-</html> 
 ====== Boost C++ Libraries ====== ====== Boost C++ Libraries ======
 {{c_cpp:boost_c_libraries.png?277|Boost C++ Libraries}}\\ {{c_cpp:boost_c_libraries.png?277|Boost C++ Libraries}}\\
-[[https://www.boost.org/|Boost C++ Libraries]]\\ +本家: [[https://www.boost.org/|Boost C++ Libraries]]\\ 
-[[https://github.com/boostorg|Boost.org · GitHub]]\\ +ソースコード: [[https://github.com/boostorg|Boost.org · GitHub]]\\
-\\ +
-Boost (ブースト)とは、C++の先駆的な開発者のコミュニティ、およびそのコミュニティによって公開されているオープンソースのソフトウェアライブラリのことを指す。コミュニティとしてのBoostはC++標準化委員会の委員により設立されており、現在でもその多くが構成員として留まっている。このような経緯もあり、BoostコミュニティはC++の標準化において大きな影響力を有している。実際に標準化委員会が発表した「TR1」の2/3以上がBoostライブラリを基にしている。Random, Regex, ThreadなどはいずれもC++11規格の標準ライブラリとして正式に導入・標準化されている。このことから、Boostは考案された新機能を標準化させる前の試験運用の場であるとも言える。\\ +
-\\ +
-Boostで公開されるライブラリはコミュニティの公開レビューによって精選されている。Boostを使用して作成したプログラムは、商用、非商用を問わず無償のBoost Software Licenseの下でライセンスされる。\\ +
-\\ +
-Boostはテンプレートなどを活用して積極的にメタプログラミングやジェネリックプログラミングの技法を取り入れて行く傾向がある。そのためBoostライブラリの利用者にはC++の現代的な記述に慣れていることを要求される。\\+
 \\ \\
 +**Boost** (ブースト) とは、C++ の先駆的な開発者のコミュニティ、およびそのコミュニティによって公開されているオープンソースのソフトウェアライブラリのことを指す。コミュニティとしての Boost は C++ 標準化委員会の委員により設立されており、現在でもその多くが構成員として留まっている。このような経緯もあり、Boost コミュニティは C++ の標準化において大きな影響力を有している。実際に標準化委員会が発表した「TR1」の2/3以上が Boost ライブラリを基にしている。Random, Regex, Thread などはいずれも C++11 規格の標準ライブラリとして正式に導入・標準化されている。このことから、Boost は考案された新機能を標準化させる前の試験運用の場であるとも言える。\\
 +
 +Boost で公開されるライブラリはコミュニティの公開レビューによって精選されている。Boost を使用して作成したプログラムは、商用、非商用を問わず無償の Boost Software License の下でライセンスされる。\\
 +
 +Boost はテンプレートなどを活用して積極的にメタプログラミングやジェネリックプログラミングの技法を取り入れて行く傾向がある。そのため Boost ライブラリの利用者には C++ の現代的な記述に慣れていることを要求される。\\
 +
 このライブラリは、先鋭的な技術を好むプログラマーが積極的に使用していることで有名である。\\ このライブラリは、先鋭的な技術を好むプログラマーが積極的に使用していることで有名である。\\
-\\+
 [[https://ja.wikipedia.org/wiki/Boost_C%2B%2B%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA|Boost C++ライブラリ - Wikipedia]] より\\ [[https://ja.wikipedia.org/wiki/Boost_C%2B%2B%E3%83%A9%E3%82%A4%E3%83%96%E3%83%A9%E3%83%AA|Boost C++ライブラリ - Wikipedia]] より\\
  
行 45: 行 17:
  
 ===== 利用する前にビルドの必要があるライブラリ ===== ===== 利用する前にビルドの必要があるライブラリ =====
- Boostに含まれる以下のライブラリを利用する場合は、事前にビルドを行う必要がある。それ以外は、ヘッダファイルを #include することで、そのまま利用することが可能である。\\+ Boost に含まれる以下のライブラリを利用する場合は、事前にビルドを行う必要がある。それ以外は、ヘッダファイルを #include することで、そのまま利用することが可能である。\\
 \\ \\
  ビルドが必要なライブラリ  ビルドが必要なライブラリ
行 62: 行 34:
   * **...**   * **...**
  
-===== Visual Studio へのインストール =====+===== ダウンロード ===== 
 +Visual Studio へ [[windows:visualstudio#vcpkg_コマンド|Vcpkg コマンド]] を利用してインストールする場合、または、Linux へ dnf コマンドを利用して rpm パッケージをインストールする場合は、ソースコードをダウンロードしなくてもインストールすることができる。\\ 
 +ソースコードから最新版をビルドしたい場合は、以下のいずれかの方法でダウンロードする必要がある。\\ 
 + 
 +==== GitHub より ==== 
 +GitHub より最新をダウンロードするには以下のコマンドを実行する。 
 +<code> 
 +$ git clone --recursive https://github.com/boostorg/boost.git 
 +</code> 
 +※**--recursive** 無しで clone してしまった場合は以下のコマンドを実行する。 
 +<code> 
 +$ cd boost 
 +$ git submodule --init --recursive 
 +</code> 
 +最新をダウンロードし直す場合は以下のコマンドを実行する。 
 +<code> 
 +$ cd boost 
 +$ git pull 
 +</code> 
 + 
 +==== 公式ページより ==== 
 +  - [[https://www.boost.org/|Boost C++ Libraries]] の [[https://www.boost.org/users/download/|Boost Downloads]] より [[https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.7z|boost_1_74_0.7z]] をダウンロードする。\\ 
 +  - Windows の場合は boost_1_74_0.7z を C:\Libraries\ などに解凍する。\\ 
 + 
 +===== Windows でのインストール ===== 
 + 
 +==== Visual Studio - Vcpkg 編 ====
 [[windows:visualstudio#vcpkg_コマンド|Visual Studio - Vcpkg コマンド]] をインストールする。\\ [[windows:visualstudio#vcpkg_コマンド|Visual Studio - Vcpkg コマンド]] をインストールする。\\
 PowerShell で以下のコマンドを実行する。\\ PowerShell で以下のコマンドを実行する。\\
行 2087: 行 2085:
 </WRAP> </WRAP>
  
-===== ダウンロード ===== +==== スコードからビルド ==== 
- +内容は正式対応前に **Visual Studio 2019 Preview** で最新の **Boost** ースからビルドした。\\ 
-==== GitHub ==== +**Boost** が正式対応しているコンパイラでは、これほど苦労はしな。\\
-GitHub より最新をダウンロードするには以下のコマンドを実行する。 +
-<code> +
-$ git clone --recursive https://github.com/boostorg/boost.git +
-</code> +
-**--recursive** 無しで clone してしまった場合は以下のコマンドを実行する。 +
-<code> +
-$ cd boost +
-$ git submodule --init --recursive +
-</code> +
-最新をダウンロードし直す場合は以下コマンドを実行する。 +
-<code> +
-$ cd boost +
-$ git pull +
-</code> +
- +
-==== 公式ページより ==== +
-  - [[https://www.boost.org/|Boost C++ Libraries]] の [[https://www.boost.org/users/download/|Boost Downloads]] より [[https://dl.bintray.com/boostorg/release/1.74.0/source/boost_1_74_0.7z|boost_1_74_0.7z]] ダウンロドする。\\ +
-  - Windows の場合は boost_1_74_0.7z を C:\Libraries\ などに解凍する。\\ +
- +
-===== Linux でのインル ===== +
-Fedora 29\\ +
-<WRAP prewrap 100%> +
-<code> +
-$ sudo dnf install boost boost-devel boost-date-time boost-filesystem boost-graph boost-iostreams boost-numpy3 boost-program-options boost-python3 boost-python3-devel boost-regex boost-serialization boost-signals boost-stacktrace boost-static boost-system boost-test boost-thread boost-timer boost-type_erasure boost-wave +
-</code> +
-</WRAP> +
-以下の依存関係がインストールされる。\\ +
-<WRAP prewrap 100%> +
-<code> +
-libquadmath-devel boost-container boost-context boost-coroutine boost-fiber boost-log boost-math python3-numpy +
-</code> +
-</WRAP> +
- +
-[[c_cpp:boost:fedora_29_boost_rpms|Fedora 29 でインストール可能な Boost の RPM 一覧]]\\ +
-==== ソースからビルド ==== +
-<code> +
-$ cd boost +
-$ ./bootstrap.sh +
-$ PYTHON_ROOT=/usr/bin/python3 +
-$ PYTHON_VERSION=3.7 +
-$ echo "using gcc : 8.3 : /usr/bin/g++ ; " >> tools/build/src/user-config.jam +
-$ ./bjam --toolset=gcc-8.3 address-model=32 architecture=x86 variant=debug -j 3 --buildid=x32-d +
-$ ./bjam --toolset=gcc-8.3 address-model=64 architecture=x86 variant=debug -j 3 --buildid=x64-d +
-$ ./bjam --toolset=gcc-8.3 address-model=32 architecture=x86 variant=release -j 3 --buildid=x32 +
-$ ./bjam --toolset=gcc-8.3 address-model=64 architecture=x86 variant=release -j 3 --buildid=x64 +
-</code> +
-※**Name clash for xxx**エラーが発生する場合は、**address-model=64 architecture=x86**オプションで回避できる。\\ +
-**-j N** は並列コンパイル数 N を指定する。\\ +
-※**variant=debug,release**にすると**address-model=64 architecture=x86**を指定しても**Name clash for xxx**エーが発生てビルドできかった。\\ +
-※**--buildid=d**はデバッグ版のライブラリ名に-dを付ける。\\ +
- +
-===== ビルド/インストール ===== +
- +
-==== Windows 上の Visual C++ 2019 Preview でビルドする場合 ====+
   - タスクバーの「ここに入力して検索」に sysdm.cpl を入力して Enter キーを押す。   - タスクバーの「ここに入力して検索」に sysdm.cpl を入力して Enter キーを押す。
   - 「システムのプロパティ」の「詳細設定」タブの[環境変数]ボタンを押して「環境変数」画面を開く。   - 「システムのプロパティ」の「詳細設定」タブの[環境変数]ボタンを押して「環境変数」画面を開く。
行 2154: 行 2098:
 > cd %BOOST% > cd %BOOST%
 > bootstrap.bat > bootstrap.bat
 +</code></WRAP><WRAP prewrap 100% #result><code>
 Building Boost.Build engine Building Boost.Build engine
  
行 2178: 行 2123:
     http://www.boost.org/build/     http://www.boost.org/build/
 </code></WRAP> </code></WRAP>
-  - 現時点で bjam は Visual Studio 2019 に対応していないので msvc.jam を修正する。<file diff %BOOST%\tools\build\src\tools\msvc.jam.patch>+  - 現時点で bjam は **Visual Studio 2019 Preview** に対応していないので msvc.jam を修正する。<WRAP prewrap 100% mincode><file diff %BOOST%\tools\build\src\tools\msvc.jam.patch>
 24d23 24d23
 < * Visual Studio 2019—14.2 < * Visual Studio 2019—14.2
行 2214: 行 2159:
 2012d2001 2012d2001
 < .version-14.2-env = VS160COMNTOOLS ProgramFiles ProgramFiles(x86) ; < .version-14.2-env = VS160COMNTOOLS ProgramFiles ProgramFiles(x86) ;
-</file>+</file></WRAP>
     - *** Visual Studio 2019—14.2** コメント追加。     - *** Visual Studio 2019—14.2** コメント追加。
     - **if [ MATCH "(14.1)" : $(version) ]** を **if [ MATCH "(14.[12])" : $(version) ]** に修正。     - **if [ MATCH "(14.1)" : $(version) ]** を **if [ MATCH "(14.[12])" : $(version) ]** に修正。
     - **exact-version = [ MATCH "(14\.10\.[0-9\.]+)" : $(command) ] ;** を **exact-version = [ MATCH "(14\.[12]0\.[0-9\.]+)" : $(command) ] ;** に修正。     - **exact-version = [ MATCH "(14\.10\.[0-9\.]+)" : $(command) ] ;** を **exact-version = [ MATCH "(14\.[12]0\.[0-9\.]+)" : $(command) ] ;** に修正。
-    - **if [ MATCH "(MSVC\\14.1)" : $(command) ]** を <code autoconf>+    - **if [ MATCH "(MSVC\\14.1)" : $(command) ]** を <WRAP prewrap 100% mincode><code autoconf>
 if [ MATCH "(MSVC\\14.2)" : $(command) ] if [ MATCH "(MSVC\\14.2)" : $(command) ]
 { {
行 2224: 行 2169:
 } }
 else if [ MATCH "(MSVC\\14.1)" : $(command) ] else if [ MATCH "(MSVC\\14.1)" : $(command) ]
-</code> に修正。+</code></WRAP> に修正。
     - **if $(version) = 14.1 || $(version) = "default"** を **if $(version) = 14.1 || $(version) = 14.2 || $(version) = "default"** に修正。     - **if $(version) = 14.1 || $(version) = "default"** を **if $(version) = 14.1 || $(version) = 14.2 || $(version) = "default"** に修正。
     - **.known-versions = 14.1 14.0 12.0 11.0 10.0 10.0express 9.0 9.0express 8.0 8.0express 7.1** を **.known-versions = 14.2 14.1 14.0 12.0 11.0 10.0 10.0express 9.0 9.0express 8.0 8.0express 7.1** に修正。     - **.known-versions = 14.1 14.0 12.0 11.0 10.0 10.0express 9.0 9.0express 8.0 8.0express 7.1** を **.known-versions = 14.2 14.1 14.0 12.0 11.0 10.0 10.0express 9.0 9.0express 8.0 8.0express 7.1** に修正。
     - **.version-alias-14.2 = 14.2 ;** を追記。     - **.version-alias-14.2 = 14.2 ;** を追記。
-    - <code autoconf>+    - <WRAP prewrap 100% mincode><code autoconf>
 .version-14.2-path = .version-14.2-path =
      "../../VC/Tools/MSVC/*/bin/Host*/*"      "../../VC/Tools/MSVC/*/bin/Host*/*"
      "Microsoft Visual Studio/2019/Preview/VC/Auxiliary/Build"      "Microsoft Visual Studio/2019/Preview/VC/Auxiliary/Build"
      ;      ;
-</code> を追記。+</code></WRAP> を追記。
     - **.version-14.2-env = VS160COMNTOOLS ProgramFiles ProgramFiles(x86) ;** を追記。     - **.version-14.2-env = VS160COMNTOOLS ProgramFiles ProgramFiles(x86) ;** を追記。
-  - 「スタート」の「Visual Studio 2019」より「x86 Native Tools Command Prompt for VS 2019」または「x64 Native Tools Command Prompt for VS 2019」を起動して、以下のコマンドを入力する。<code>+  - 「スタート」の「Visual Studio 2019」より「x86 Native Tools Command Prompt for VS 2019」または「x64 Native Tools Command Prompt for VS 2019」を起動して、以下のコマンドを入力する。<WRAP prewrap 100%><code>
 > bjam --toolset=msvc link=static,shared runtime-link=static,shared release debug stage > bjam --toolset=msvc link=static,shared runtime-link=static,shared release debug stage
-</code> +</code></WRAP
-  - 以下のようにコンパイルが開始される。<WRAP prewrap 100%><code>+  - 以下のようにコンパイルが開始される。<WRAP prewrap 100% #result><code>
 Performing configuration checks Performing configuration checks
  
行 2259: 行 2204:
 === auto_link.hpp の修正 === === auto_link.hpp の修正 ===
 現時点で boost は Visual Studio 2019 のオートリンクに対応していないので auto_link.hpp を修正する。 現時点で boost は Visual Studio 2019 のオートリンクに対応していないので auto_link.hpp を修正する。
 +<WRAP prewrap 100% mincode>
 <file diff %BOOST%\boost\config\auto_link.hpp.patch> <file diff %BOOST%\boost\config\auto_link.hpp.patch>
 176c176 176c176
行 2271: 行 2217:
 < #    define BOOST_LIB_TOOLSET "vc142" < #    define BOOST_LIB_TOOLSET "vc142"
 </file> </file>
 +</WRAP>
   - **#  elif defined(BOOST_MSVC)** を **#  elif defined(BOOST_MSVC) && (BOOST_MSVC < 1920)** に修正。   - **#  elif defined(BOOST_MSVC)** を **#  elif defined(BOOST_MSVC) && (BOOST_MSVC < 1920)** に修正。
-  - <code cpp>+  - <WRAP prewrap 100% mincode><code cpp>
 #  elif defined(BOOST_MSVC) #  elif defined(BOOST_MSVC)
    
      // vc14.2:      // vc14.2:
 #    define BOOST_LIB_TOOLSET "vc142" #    define BOOST_LIB_TOOLSET "vc142"
-</code> を追記。+</code></WRAP> を追記。
  
 === 参考 === === 参考 ===
 +<WRAP prewrap 100% mintbl>
 ^  表記  ^  製品名  ^  VC++ Version  ^  _MSC_VER  ^  _MSC_FULL_VER  ^ ^  表記  ^  製品名  ^  VC++ Version  ^  _MSC_VER  ^  _MSC_FULL_VER  ^
 | 2019  | Visual Studio 2019\\ Version 16.1.2  |  14.21  |  1921 |  192127702 | | 2019  | Visual Studio 2019\\ Version 16.1.2  |  14.21  |  1921 |  192127702 |
 | 2019 Preview  | Visual Studio Enterprise 2019 Preview\\ Version 16.0.0 Preview 2.2  |  14.20  |  1920 |  192027305 | | 2019 Preview  | Visual Studio Enterprise 2019 Preview\\ Version 16.0.0 Preview 2.2  |  14.20  |  1920 |  192027305 |
 | 2017 Update 7  | Visual Studio 2017 Version 15.7.5  |  14.14  |  1914 |  191426433 | | 2017 Update 7  | Visual Studio 2017 Version 15.7.5  |  14.14  |  1914 |  191426433 |
 +</WRAP>
 [[windows:visualstudio#visual_studio_と_vc_マクロ定義|Visual Studio と VC++ マクロ定義]]\\ [[windows:visualstudio#visual_studio_と_vc_マクロ定義|Visual Studio と VC++ マクロ定義]]\\
  
-===== 利用方法 ===== +===== Linux でのインストール ===== 
-[[c_cpp:boost:boost_python|Boost.Python]] - Boost Python Library は、Python と C++ を連携させるためのフレムワークです。Dave Abrahams の C++ コンパイラだけで、特別なツールを使用するなく、C++ クラスの関数やオブジェクトを Python に素早くシムレスに公開できる。\\+Fedora 29\\ 
 +<WRAP prewrap 100%> 
 +<code> 
 +$ sudo dnf install boost boost-devel boost-date-time boost-filesystem boost-graph boost-iostreams boost-numpy3 boost-program-options boost-python3 boost-python3-devel boost-regex boost-serialization boost-signals boost-stacktrace boost-static boost-system boost-test boost-thread boost-timer boost-type_erasure boost-wave 
 +</code> 
 +</WRAP> 
 + 
 +以下の依存関係がインストールされる。\\ 
 +<WRAP prewrap 100%> 
 +<code> 
 +libquadmath-devel boost-container boost-context boost-coroutine boost-fiber boost-log boost-math python3-numpy 
 +</code> 
 +</WRAP> 
 + 
 +[[c_cpp:boost:fedora_29_boost_rpms|Fedora 29 でインストール可能な Boost の RPM 一覧]]\\ 
 + 
 +==== ソースからのビルド ==== 
 +<code> 
 +$ cd boost 
 +$ ./bootstrap.sh 
 +$ PYTHON_ROOT=/usr/bin/python3 
 +$ PYTHON_VERSION=3.7 
 +$ echo "using gcc : 8.3 : /usr/bin/g++ ; " >> tools/build/src/user-config.jam 
 +$ ./bjam --toolset=gcc-8.3 address-model=32 architecture=x86 variant=debug -j 3 --buildid=x32-d 
 +$ ./bjam --toolset=gcc-8.3 address-model=64 architecture=x86 variant=debug -j 3 --buildid=x64-d 
 +$ ./bjam --toolset=gcc-8.3 address-model=32 architecture=x86 variant=release -j 3 --buildid=x32 
 +$ ./bjam --toolset=gcc-8.3 address-model=64 architecture=x86 variant=release -j 3 --buildid=x64 
 +</code> 
 +※**Name clash for xxx**エラが発生る場合は、**address-model=64 architecture=x86**オプションで回避できる\\ 
 +※**-j N** は並列コンパイル数 N 指定する。\\ 
 +※**variant=debug,release**にすると**address-model=64 architecture=x86**指定しても**Name clash for xxx**エラが発生してビルドできなかった。\\ 
 +※**--buildid=d**はデバッグ版のライブラリ名に-dを付ける。\\ 
 + 
 + 
 +===== ライブラリの利用方法 ===== 
 +[[c_cpp:boost:boost_python|Boost.Python - Boost Python Library]]\\
  
 ===== 参考文献 ===== ===== 参考文献 =====
 [[https://boostjp.github.io/howtobuild.html|Boostライブラリのビルド方法 - boostjp]]\\ [[https://boostjp.github.io/howtobuild.html|Boostライブラリのビルド方法 - boostjp]]\\
 +[[git>boost-ext/di|boost-ext/di: DI: C++14 Dependency Injection Library]]\\
  
 +==== 付録 ====
 +[[tw>tomoyan596/status/1404143924428480512|〇 DI (Dependency Injection) × PI(Pregnancy Injection) YouTubeの字幕がおかしいだけですねぇ😅💦 / Twitter]]\\
  
  • c_cpp/boost.1598465303.txt.gz
  • 最終更新: 2020/08/27 03:08
  • by ともやん