|
Boost Users : |
Subject: Re: [Boost-users] boost::python::import causes access violation
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-02-08 12:08:36
At Fri, 4 Feb 2011 14:08:11 +0000,
Julian Bailey wrote:
>
> Hi,
>
> I am running through the basic examples on the boost website for embedding boost::python.
>
> My code currently reads:
>
> #include <iostream>
>
> #include "./include/Python.h"
> #include "./boost/python.hpp"
>
> using namespace boost::python;
>
> int main(void)
> {
> Py_Initialize();
>
> object main_module = import("__main__");
> object main_namespace = main_module.attr("__dict__");
>
> object ignored = exec("print Hello world",main_namespace);
>
> return 0;
> }
>
> The program links successfully and begins running, however an access violation occurs (NULL pointer) at the first line after "py_initialize();" when i call import("__main__");
Do you have a complete stack backtrace?
> Visual studio 2010s debugger says the exception occurs at: line 74 in object_attributes.hpp:
>
> inline object const_attribute_policies::get(object const& target, char const* key)
> {
> return python::getattr(target, key);
> }
>
>
> Python was built using Visual studio 2010 so i had access to the python debug
> library.
Yeah, but you can't use the python debug library unless you are also passing
python-debugging=on to your Boost build as described in
http://www.boost.org/doc/libs/1_45_0/libs/python/doc/building.html#python-debugging-builds
. Are you doing that? If not, a crash is to be expected.
> Boost is version 1.45 and was built using :
>
> bjam --build-type=complete msvc stage --with-python
>
> I am linking against:
> boost_python-vc100-mt-gd-1_45.lib
> and
> boost_python-vc100-mt-gd-1_45.dll
>
> I have looked for soutions on the internet and have found nothing right now. Can anyone help me?
>
> note: i am building my application in MSVC 2010, this should work though shouldn't it?
It should.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net