I have a library that has a class: class MainC { private: std::vector <int> i_vec; public: MainC(){}; inline std::vector <int> getVec(return i_vec;); } a function that returns a object of the first class: MainC getClass() { MainC mc; return mc; } and a wrapper since I want to expose a vector to python WrapperMainC : ..
Category : boost-python
I’m trying to wrap my C++ library with boost-python. However, I’m running into trouble getting the program to run when I try to add boost-python (it is able to compile). When the program runs, it throws the following error: dyld: Symbol not found: _PyBaseObject_Type Referenced from: /usr/local/opt/boost-python3/lib/libboost_python39-mt.dylib Expected in: flat namespace in /usr/local/opt/boost-python3/lib/libboost_python39-mt.dylib I made ..
I am looking for a way to iterate through python dict (without creating tmp list object). After some little research I came to this. boost::python::object dictItemsView(const boost::python::dict& dict) { #if PY_MAJOR_VERSION >= 3 return dict.items(); #else return dict.iteritems(); #endif } template <typename Func> void iterDict(const boost::python::dict& dict, Func func) { boost::python::handle<> iterH(boost::python::allow_null<>(PyObject_GetIter(dictItemsView(dict).ptr()))); if (!iterH.get()) { ..
I’m trying to use Boost Python to use my C++ function in Python. main.cpp contains a hello world function. I want to link Boost Python using Conan. I’ve used Conan before for libpqxx which worked fine but I’m getting a fatal error with Boost Python. ERROR MESSAGE In file included from /Users/jin/github/cpp_test_3/main.cpp:1: In file included ..
Similar questions here How can I call linux shared library functions in Go? but too a beginner to understand it. I am a C programmer and learning Go in a hard way. Currently studying and porting an existing Python codes (python1.py and python3.py) to Go The existing Python files(along with delphi.cpp) have been compiled and ..
I successfully used Boost Python to write C++ functions with Numpy array arguments. But I’m struggling with a very basic case: when my function has to return a value. There’s no problem until I try to read the int returned by my function. I strongly suspect my setup has something to do with this, but ..
Currently, I am calling an extended C++ module from Go. The problem is not in Go but the way the data structure is designed to call the python function Note: (1) This cfolder (with .cpp) is C++ extension (2) The main.py calls .cpp via Python runtime (3) I am reproducing main.py in Go (calling cfolder ..
Hi all I have a question how to bring c++ complex objects to work in python via boost-python. How to convert a c++ function which returns one of the following types to a function returning an equivialent python object: Map Vector … Something like the following example, which should return a python dict obj due ..
I am having problems passing back an <std::vector <std::vector <boost::shared_ptr Detection>>> and I was hoping someone could help me out. I am able to pass the vector of vector but when I try and access the Detection, I get a TypeError that there is no python class registered for C++ class boost::shared_ptr which is in ..

I’m trying to create boost python module and test producer & consumer problem. But I faced some error and problems… Below image shows my goal architecture. I implemented boost python module (github) and here is python code snippet (main.py) import threading import datetime import PyDataTest queue = None def thread_function(): print(‘[thread_function] start…’) while True: print(‘[thread_function] ..
Recent Comments