From Opitz.student at mmi.rwth-aachen.de Sat Nov 2 15:17:08 2013 From: Opitz.student at mmi.rwth-aachen.de (Tobias Opitz) Date: Sat, 2 Nov 2013 14:17:08 +0000 Subject: [C++-sig] Error importing a python module in c++ Message-ID: Hello mailinglist, I'm having trouble embedding python into c++. I use msvc-9.0, building 32-bit on a 64-architecture running win7pro. My Python version is 2.7.5. I have a python release and debug version (every file in C.\python27\libs exists with and without _d) I would like to embed a couple of python scripts into a c++-application. Therefore I first tried to use the standard Python C-API. The problem I encountered during this is the same as described here. So I tried to use boost.python but this was neither successfully. I'm receiving a acces violation. Here is my example source code: #include // without this line the compiler criticizes a missing python27.lib - // but I'm trying to build a debug-variant... #include #include int main() { std::cout << "Boost.Python Test" << std::endl; // Start Python interpreter Py_Initialize(); // Setup sys.path boost::python::object sys = boost::python::import("sys"); // => throws "0x00000000 in Python_C_API_Test.exe: 0xC0000005: Access violation." in boost/libs/python/src/import.cpp boost::python::list path = boost::python::extract(sys.attr("path")); std::cout << "Module loaded" << std::endl; return 0; } I have build boost.python a dozend times with different flags. ("D:\boost_1_53_0>b2 --build-dir="D:\boost_1_53_0\python" toolset=msvc-9.0 link=shared variant=debug --python-debugging python" and using the resulting "boost_python-vc90-mt-gd-1_53.lib" What could I have missed? Do you have any solutions or approachs for me? Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rmorettiase at gmail.com Mon Nov 25 19:07:53 2013 From: rmorettiase at gmail.com (Rocco Moretti) Date: Mon, 25 Nov 2013 12:07:53 -0600 Subject: [C++-sig] Wrapping Boost graph vertex/edge descriptors (void pointers) with Boost.Python Message-ID: Hello all, We have a C++ library that uses the Boost graph library, and has functions which return and take the boost graph vertex and edge descriptors. The issue I'm running into with using Boost.Python is that for the implementation of the graph that we've chose (the listS/listS one), the edge and vertex descriptors are internally implemented as void pointers. Not using void pointers isn't an option (the use of void pointers is a choice by Boost graph for the style of graph we're using, which has other considerations feeding into it). I don't really need to interact with the vertex and edge descriptors at all at the Python level, aside from passing them around and then back to other C++ level functions (and perhaps doing equality comparisons, but that's not strictly necessary). I certainly don't need to dereference them or type convert them. Even at the C++ level we never deal with them as actual void pointers, instead having them be typedefed, and using that consistent typedefed type as an opaque type. What would be the best way to have Boost.Python deal with these edge and vertex descriptors? I looked at opaque pointer policy stuff, but from what I can tell so far, that doesn't really work with void pointers. Thank You, -Rocco -------------- next part -------------- An HTML attachment was scrubbed... URL: