boost-python

How to Build Using the Boost Python Libraries in VS2017

两盒软妹~` 提交于 2019-12-11 07:36:54
问题 I have built the Boost 1.64.0 Python libraries, using MS Visual Studio Professional 2017 and 32-bit Python 3.4. Now, when I write an application against the resulting library, I'm getting the following link error: LINK : fatal error LNK1104: cannot open file 'libboost_python-vc141-mt-1_64.lib' I have looked in the stage/lib directory, and indeed, the library is named libboost_python 3 -vc141-mt-1_64.lib (note the 3 in the name). I'm assuming the 3 is referencing the fact that the Boost Python

How to expose C++ classes with const_iterator

陌路散爱 提交于 2019-12-11 06:38:18
问题 I am using Boost.Python to expose a 3rd party C++ API. A header file I've come to declares an iterable class (has begin and end methods), and a custom iterator class with which to do the iteration:- // File: data.hpp #include <utility> // for std::pair #include <cstring> // for size_t namespace notmylib { // forward declaration class DataIterator; // Storage for arbitrary data class Data { public: Data(void); virtual ~Data(void); // ... typedef DataIterator const_iterator; const_iterator

Cannot successfully install Boost.Python

99封情书 提交于 2019-12-11 04:02:02
问题 I am trying to install Boost.Python on my computer. (Windows7 64bit, Visual Studio 2012, Python 2.7 64bit and Boost 1.54) Following the instruction, I've successfully installed the Boost Library, and then I have to separately install Boost.Python. However, as I followed the instruction at here. I am stuck at step 3.1.4. I input C:\boost_1_54_0\…\quickstart> bjam toolset=msvc --verbose-test test Then there are 135 unresolved external errors pop out. One of them is: exec.obj : error LNK2019:

Append C++ created object to python list and make it managed by python

半腔热情 提交于 2019-12-11 03:12:41
问题 Well, I've been checking this for a while, couldn't find an answer to it. I wanted to append an object which is exposed to python, say Foo: struct Foo { Foo(){ std::cout << "Creating a Foo object" << std::endl;} virtual ~Foo(){ std::cout << "Destroying a Foo object" << std::endl;} }; I work with the Foo inherited objects, and at some point I want to append them to a python list. For this, I created a FooWrapper, which inherits from Foo and use the copy constructor to struct FooWrapper :

intermittent error returning an internal reference with boost.python

北慕城南 提交于 2019-12-11 03:12:16
问题 I have the following class: #include <array> template<unsigned short D> class Point { private: std::array<float, D> coordinates; public: Point() { for(int i=D-1; i>=0; --i) coordinates[i] = 0.0; } Point(const Point& rhs) = default; Point& operator=(const Point& rhs) = default; ~Point() = default; float& get_ref(const unsigned short dimension) { return coordinates[dimension-1]; } }; I'm trying to wrap it with: #include <boost/python.hpp> BOOST_PYTHON_MODULE(fernpy) { using namespace boost:

Boost.Python: Fill in a passed in buffer in Python

≡放荡痞女 提交于 2019-12-11 03:06:09
问题 I was wondering whether it's possible to fill in a buffer (with the following conditions) in Python and if so how? I have a buffer in C++ that I need to fill in Python. The Address of the buffer is obtained through the GetAddress method which returns a void pointer to the buffer's address. #include <boost/smart_ptr/shared_ptr.hpp> class Foo { public: Foo(const unsigned int length) { m_buffer = boost::shared_ptr< unsigned char >( new unsigned char[ length ] ); } ~Foo(){} void* GetAddress( )

Boost.Python tutorial in Ubuntu 10.04

自古美人都是妖i 提交于 2019-12-11 02:03:28
问题 I downloaded the latest version of Boost and I'm trying to get the Boost.python tutorial up and running on Ubuntu 10.04: http://www.boost.org/doc/libs/1_43_0/libs/python/doc/tutorial/doc/html/python/hello.html I navigated to the correct directory, ran "bjam" and it compiled using default settings. I did not yet create a bjam config file. The compilation appears to have worked, but now I have no idea how to include the files in my python script. When I try to run the python hello world script,

unexpected result iterating over a boost::python vector_indexing_suite

杀马特。学长 韩版系。学妹 提交于 2019-12-11 00:18:10
问题 I have wrapped successfully a class named Composite. This class has the following method: std::vector<Composite*> Composite::getChildren(); I tried to wrap the returned std::vector using the vector_indexing_suite, in this way: [snippet] typedef std::vector<Composite*> CompositeArray; BOOST_PYTHON_MODULE(composite) { class_<CompositeArray>("CompositeArray") .def(vector_indexing_suite<CompositeArray, true>()); class_<Composite>("Composite", init<>()) ... more wrapper .def("getChildren",

Pass a type object (class, not an instance) from python to c++

对着背影说爱祢 提交于 2019-12-11 00:08:08
问题 I would like to have a boost::python-wrapped c++ function which is able to receive type (rather than an instance), a boost::python -wrapped c++ class. I can declare the wrapped function taking an object , but how to extract the type? I tried something like this, but type objects don't seem to be extract -able: #include<boost/python.hpp> namespace py=boost::python; struct A {}; struct B: public A {}; int func(py::object klass) { py::extract<std::type_info> T(klass); if(!T.check()) throw std:

Boost::python: object destroys itself inside a overriden method

夙愿已清 提交于 2019-12-10 21:34:22
问题 While embedding python in my application I've faced with problem related to python objects lifetime. My application expands some classes with virtual methods to python, so they can be derived and extended by python code. Application is using python interpreter and calls virtual methods of objects. The problem is that when object's reference counter reaches zero inside of python overridden method, which was called from c++ code, interpreter destroys object immediately. So, if we call such