c_cpp:boost:boost_python

差分

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

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
c_cpp:boost:boost_python [2020/08/27 19:55] – [ソリューション内の Python プロジェクトで C++ 拡張機能 プロジェクトを参照する] ともやんc_cpp:boost:boost_python [2021/07/05 01:59] (現在) ともやん
行 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.Python - Boost Python Library ====== ====== Boost.Python - Boost Python Library ======
 +本家: [[https://www.boost.org/doc/libs/release/libs/python/|Boost.Python - Boost Library Documentation]]\\
 +
 **Boost Python Library** は、Python と C++ を連携させるためのフレームワークである。Dave Abrahams の C++ コンパイラだけで、特別なツールを使用することなく、C++ クラスの関数やオブジェクトを Python に素早くシームレスに公開できる。\\ **Boost Python Library** は、Python と C++ を連携させるためのフレームワークである。Dave Abrahams の C++ コンパイラだけで、特別なツールを使用することなく、C++ クラスの関数やオブジェクトを Python に素早くシームレスに公開できる。\\
  
行 42: 行 16:
 {{c_cpp:visualstudio2019_boost.python_001.png?600|Visual Studio 2019 Boost.Python 001}}\\ {{c_cpp:visualstudio2019_boost.python_001.png?600|Visual Studio 2019 Boost.Python 001}}\\
  
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code> <code>
 言語: Python 言語: Python
行 53: 行 27:
  
 以下の内容で新しいプロジェクトを構成して **[作成]** をクリックする。\\ 以下の内容で新しいプロジェクトを構成して **[作成]** をクリックする。\\
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code> <code>
 プロジェクト名: PyHelloBoostPython プロジェクト名: PyHelloBoostPython
行 95: 行 69:
  
 **PyHelloBoostPython** プロジェクトの **PyHelloBoostPython.py** ファイルに以下のコードを貼り付ける。\\ **PyHelloBoostPython** プロジェクトの **PyHelloBoostPython.py** ファイルに以下のコードを貼り付ける。\\
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code python PyHelloBoostPython.py> <code python PyHelloBoostPython.py>
 #!/usr/bin/env python #!/usr/bin/env python
行 156: 行 130:
 {{c_cpp:visualstudio2019_boost.python_005.png?600|Visual Studio 2019 Boost.Python 005}}\\ {{c_cpp:visualstudio2019_boost.python_005.png?600|Visual Studio 2019 Boost.Python 005}}\\
  
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code> <code>
 言語: C++ 言語: C++
行 167: 行 141:
  
 以下の内容で新しいプロジェクトを構成して **[作成]** をクリックする。\\ 以下の内容で新しいプロジェクトを構成して **[作成]** をクリックする。\\
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code> <code>
 プロジェクト名: superfastcode_cpython プロジェクト名: superfastcode_cpython
行 177: 行 151:
 **superfastcode_cpython** プロジェクトを右クリックして、**[追加] - [新しい項目...]** をクリックする。\\ **superfastcode_cpython** プロジェクトを右クリックして、**[追加] - [新しい項目...]** をクリックする。\\
 以下の内容で新しい項目を追加する。\\ 以下の内容で新しい項目を追加する。\\
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code> <code>
 種類: C++ ファイル (.cpp) 種類: C++ ファイル (.cpp)
行 193: 行 167:
 これにより、**Debug、Release、Win32、x64** のすべての組み合わせについての設定を変更する。\\ これにより、**Debug、Release、Win32、x64** のすべての組み合わせについての設定を変更する。\\
 **CPython プロジェクト** (Python 用 C++ 拡張機能) のビルドに必要な設定の概要は以下の通りである。\\ **CPython プロジェクト** (Python 用 C++ 拡張機能) のビルドに必要な設定の概要は以下の通りである。\\
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code> <code>
 [構成プロパティ] - [全般] - [構成の種類]: ダイナミック ライブラリ (.dll) [構成プロパティ] - [全般] - [構成の種類]: ダイナミック ライブラリ (.dll)
行 226: 行 200:
  
 **superfastcode_cpython** プロジェクトの **cpython_module.cpp** ファイルに以下の内容を貼り付ける。\\ **superfastcode_cpython** プロジェクトの **cpython_module.cpp** ファイルに以下の内容を貼り付ける。\\
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code cpp cpython_module.cpp> <code cpp cpython_module.cpp>
 #include <Windows.h> #include <Windows.h>
行 279: 行 253:
 {{c_cpp:visualstudio2019_boost.python_005.png?600|Visual Studio 2019 Boost.Python 005}}\\ {{c_cpp:visualstudio2019_boost.python_005.png?600|Visual Studio 2019 Boost.Python 005}}\\
  
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code> <code>
 言語: C++ 言語: C++
行 290: 行 264:
  
 以下の内容で新しいプロジェクトを構成して **[作成]** をクリックする。\\ 以下の内容で新しいプロジェクトを構成して **[作成]** をクリックする。\\
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code> <code>
 プロジェクト名: superfastcode_boost プロジェクト名: superfastcode_boost
行 300: 行 274:
 **superfastcode_boost** プロジェクトを右クリックして、**[追加] - [新しい項目...]** をクリックする。\\ **superfastcode_boost** プロジェクトを右クリックして、**[追加] - [新しい項目...]** をクリックする。\\
 以下の内容で新しい項目を追加する。\\ 以下の内容で新しい項目を追加する。\\
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code> <code>
 種類: C++ ファイル (.cpp) 種類: C++ ファイル (.cpp)
行 313: 行 287:
 これにより、**Debug、Release、Win32、x64** のすべての組み合わせについての設定を変更する。\\ これにより、**Debug、Release、Win32、x64** のすべての組み合わせについての設定を変更する。\\
 **Boost.Python プロジェクト** (Python 用 C++ 拡張機能) のビルドに必要な設定の概要は以下の通りである。\\ **Boost.Python プロジェクト** (Python 用 C++ 拡張機能) のビルドに必要な設定の概要は以下の通りである。\\
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code> <code>
 [構成プロパティ] - [全般] - [構成の種類]: ダイナミック ライブラリ (.dll) [構成プロパティ] - [全般] - [構成の種類]: ダイナミック ライブラリ (.dll)
行 346: 行 320:
  
 **superfastcode_boost** プロジェクトの **boost_module.cpp** ファイルに以下の内容を貼り付ける。\\ **superfastcode_boost** プロジェクトの **boost_module.cpp** ファイルに以下の内容を貼り付ける。\\
-<WRAP prewrap 100% #mincode>+<WRAP prewrap 100% mincode>
 <code cpp boost_module.cpp> <code cpp boost_module.cpp>
 #include <Windows.h> #include <Windows.h>
行 379: 行 353:
  
 **アクティブ ソリューション構成: Debug** に変更して、以下のプロジェクトが **Release ビルド**、**x64 プラットフォーム** でビルドされるように設定する。(標準では Python の **python38.lib (Release 版)** のみのため)\\ **アクティブ ソリューション構成: Debug** に変更して、以下のプロジェクトが **Release ビルド**、**x64 プラットフォーム** でビルドされるように設定する。(標準では Python の **python38.lib (Release 版)** のみのため)\\
-<WRAP prewrap 100% #mintbl>+<WRAP prewrap 100% mintbl>
 ^  プロジェクト  ^  構成  ^  プラットフォーム  ^  ビルド  ^ ^  プロジェクト  ^  構成  ^  プラットフォーム  ^  ビルド  ^
 |superfastcode_boost  |Release  |x64  |  [v]  | |superfastcode_boost  |Release  |x64  |  [v]  |
行 388: 行 362:
  
 **アクティブ ソリューション構成: Release** に変更して、以下のプロジェクトが **Release ビルド**、**x64 プラットフォーム** でビルドされるように設定する。(標準では Python の **python38.lib (Release 版)** のみのため)\\ **アクティブ ソリューション構成: Release** に変更して、以下のプロジェクトが **Release ビルド**、**x64 プラットフォーム** でビルドされるように設定する。(標準では Python の **python38.lib (Release 版)** のみのため)\\
-<WRAP prewrap 100% #mintbl>+<WRAP prewrap 100% mintbl>
 ^  プロジェクト  ^  構成  ^  プラットフォーム  ^  ビルド  ^ ^  プロジェクト  ^  構成  ^  プラットフォーム  ^  ビルド  ^
 |superfastcode_boost  |Release  |x64  |  [v]  | |superfastcode_boost  |Release  |x64  |  [v]  |
行 404: 行 378:
 {{c_cpp:visualstudio2019_boost.python_027.png?610|Visual Studio 2019 Boost.Python 027}}\\ {{c_cpp:visualstudio2019_boost.python_027.png?610|Visual Studio 2019 Boost.Python 027}}\\
  
-**PyHelloBoostPython** プロジェクトの**[参照]**を右クリックして、**[参照の追加...]**をクリックする。\\+**PyHelloBoostPython** プロジェクトの**[参照]**を右クリックして、**[参照の追加...]**をクリックする。\\
 {{c_cpp:visualstudio2019_boost.python_028.png?250|Visual Studio 2019 Boost.Python 028}}\\ {{c_cpp:visualstudio2019_boost.python_028.png?250|Visual Studio 2019 Boost.Python 028}}\\
  
行 410: 行 384:
 {{c_cpp:visualstudio2019_boost.python_029.png?600|Visual Studio 2019 Boost.Python 029}}\\ {{c_cpp:visualstudio2019_boost.python_029.png?600|Visual Studio 2019 Boost.Python 029}}\\
  
-以下のように **PyHelloBoostPython** プロジェクトの参照に C++ 拡張機能 プロジェクトが追加されて、検索パス (**x64\Relase**) にビルド出力の ***.pyd** ファイルが配置されるので Python プロジェクトから import することが可能になる。\\ +以下のように **PyHelloBoostPython** プロジェクトの参照に C++ 拡張機能 プロジェクトが追加されて、検索パス (**x64\Release**) にビルド出力の ***.pyd** ファイルが配置されるので Python プロジェクトから **import** することが可能になる。\\ 
 {{c_cpp:visualstudio2019_boost.python_030.png?250|Visual Studio 2019 Boost.Python 030}}\\ {{c_cpp:visualstudio2019_boost.python_030.png?250|Visual Studio 2019 Boost.Python 030}}\\
  
行 429: 行 403:
 [[https://docs.microsoft.com/ja-jp/visualstudio/python/working-with-c-cpp-python-in-visual-studio?view=vs-2019|Python 用の C++ 拡張機能の記述 - Visual Studio | Microsoft Docs]]\\ [[https://docs.microsoft.com/ja-jp/visualstudio/python/working-with-c-cpp-python-in-visual-studio?view=vs-2019|Python 用の C++ 拡張機能の記述 - Visual Studio | Microsoft Docs]]\\
 [[http://moriyoshi.hatenablog.com/entry/20091214/1260779899|Boost.Python の機能をざっと紹介してみる - moriyoshiの日記]]\\ [[http://moriyoshi.hatenablog.com/entry/20091214/1260779899|Boost.Python の機能をざっと紹介してみる - moriyoshiの日記]]\\
 +
 +[[http://alpha.osdn.jp/devel/boost.python_ja.pdf|Boost.Python - Alpha]]\\
 +[[https://qiita.com/maiueo/items/b2093ba78cde988bb111|ctypesの変数についてのメモ - Qiita]]\\
 +[[https://docs.python.org/ja/3/library/ctypes.html|ctypes --- Pythonのための外部関数ライブラリ — Python 3.8.6rc1 ドキュメント]]\\
 +[[https://stackoverflow.com/questions/16105539/boost-python-custom-converter|c++ - Boost.Python custom converter - Stack Overflow]]\\
  
  • c_cpp/boost/boost_python.1598525730.txt.gz
  • 最終更新: 2020/08/27 19:55
  • by ともやん