ユーザ用ツール

サイト用ツール


lang:c:pybind11

差分

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

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
lang:c:pybind11 [2025/08/24 11:06] editorlang:c:pybind11 [2025/09/06 12:45] (現在) – [Windows の場合] editor
行 56: 行 56:
  
 ===== complile ===== ===== complile =====
 +==== Linux/Mac の場合 ====
   c++ exPybind11.cpp -o examplePybind11.so -std=c++11 -shared -fPIC \   c++ exPybind11.cpp -o examplePybind11.so -std=c++11 -shared -fPIC \
   -I"pybindIncludeDir" \   -I"pybindIncludeDir" \
行 64: 行 64:
 "PYBIND11_MODULE(examplePybind11, m)" の第一引数と同じこと。 "PYBIND11_MODULE(examplePybind11, m)" の第一引数と同じこと。
  
-  +==== Windows の場合 ==== 
 +コンパイラや環境に依存すると思われる。\\  
 +以下は、"UCRT64/mingw-w64-ucrt-x86_64-python 3.12.11-1" の場合。 
 + 
 +  c++ exPybind11.cpp -o examplePybind11`python-config --extension-suffix` \ 
 +  -std=c++11 -shared -fPIC \ 
 +  -I"pybind11IncludeDir"
 +  `python-config --cflags --ldflags` 
 + 
 +上記の -I"pybind11IncludeDir" は環境にあわせる。 
 +----
 ===== python での使用方法 ===== ===== python での使用方法 =====
 <file python example.py> <file python example.py>
行 98: 行 108:
   }   }
  
 +</file>
 +----
 +===== threading/pthead などでの利用 =====
 +python で threading からの呼び出しでは、独立スレッドにならない。
 +独立スレッドにするために、以下のコードを挿入する。
  
 +<file c++ thread.cpp> 
 +void function(void){ 
 +  pybind11::gil_scoped_release release; 
 +  // 処理 
 +  pybind11::gil_scoped_acquire acquire; 
 +}
 </file> </file>
 +
 +
 +
lang/c/pybind11.1756033574.txt.gz · 最終更新: by editor

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki