boost

CMake boost_python not found

CMake boost_python not found Question: Hi I’m having some problems with using cmake to build this example. This is what I have: ├── _build │   ├── CMakeCache.txt │   ├── CMakeFiles │   ├── cmake_install.cmake │   └── Makefile ├── CMakeLists.txt ├── hello_ext.cpp └── README.md CMakeLists.txt: cmake_minimum_required(VERSION 3.16.3) project(test) # Find python and Boost – both are required …

Total answers: 1

boost::python – C++ calling Python calling C++

boost::python – C++ calling Python calling C++ Question: I have an application which will be extensible by Python code but the extensing code will also be using code from the application. Example of what I am trying to achieve: // wrapped_module.cpp void api_call() { std::cout << “API call” << std::endl; } BOOST_PYTHON_MODULE(API) { boost::python::def(“api_call”, api_call); …

Total answers: 1

Boost::Python, converting tuple to Python works, vector<tuple> does not

Boost::Python, converting tuple to Python works, vector<tuple> does not Question: I’ve been using Boost::Python for a while, and everything always turned out ok. However yesterday I was trying to find out why a particular type I thought I had registered (a tuple) was giving me errors when I was trying to access it from Python. …

Total answers: 1

Writing Python bindings for C++ code that use OpenCV

Writing Python bindings for C++ code that use OpenCV Question: I’m trying to write a python wrapper for some C++ code that make use of OpenCV but I’m having difficulties returning the result, which is a OpenCV C++ Mat object, to the python interpreter. I’ve looked at OpenCV’s source and found the file cv2.cpp which …

Total answers: 3

How does import work with Boost.Python from inside python files

How does import work with Boost.Python from inside python files Question: I am using Boost.Python to embed an interpreter in my C++ executable and execute some prewritten scripts. I have got it working so that I can call functions in the python file but the python code I want to use imports external files and …

Total answers: 2

Boost and Python 3.x

Boost and Python 3.x Question: How does boost.python deal with Python 3? Is it Python 2 only? Asked By: BenjaminB || Source Answers: Newer versions of Boost should work fine with Python V3.x. This support has been added quite some time ago, I believe after a successful Google Summer of Code project back in 2009. …

Total answers: 8

boost::python: Python list to std::vector

boost::python: Python list to std::vector Question: Finally I’m able to use std::vector in python using the [] operator. The trick is to simple provide a container in the boost C++ wrapper which handles the internal vector stuff: #include <boost/python.hpp> #include <vector> class world { std::vector<double> myvec; void add(double n) { this->myvec.push_back(n); } std::vector<double> show() { …

Total answers: 4

Exposing a C++ API to Python

Exposing a C++ API to Python Question: I’m currently working on a project were I had to wrap the C++ classes with Python to be able to script the program. So my specific experience also involved embedding the Python interpreter in our program. The alternatives I tried were: Boost.Python I liked the cleaner API produced …

Total answers: 5