[C++-sig] boost python in visual c++ 2008

glok_twen glok_twen at yahoo.com
Mon Apr 20 07:53:02 CEST 2009


hi. 

i have used boost python to create the sample from the doc within visual
studio. a dll has resulted. but when i copy that dll to any of numerous
places on my path, and run a python shell, i keep getting:

ImportError: no module named hello

Here is the code, it's contained in 2 modules within visual c++ (maybe that
part of the problem?):

***** first module *****

// boost_pyth_01.cpp : Defines the exported functions for the DLL
application.
//

#include <boost/python.hpp>
using namespace boost::python;


//#include "stdafx.h"

__declspec(dllexport) struct World
{
    void set(std::string msg) { this->msg = msg; }
    std::string greet() { return msg; }
    std::string msg;
};


BOOST_PYTHON_MODULE(hello)
{
    class_<World>("World")
        .def("greet", &World::greet)
        .def("set", &World::set)
    ;
}

***** and, second module *****

// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	return TRUE;
}


it does build a dll, named after my project name in the first module. i
copied this dll to numerous places on my path. still get the error above in
the python shell.

also i get this warning during the link:

1>d:\cpp_testing\boost_pyth_01\boost_pyth_01.cpp(15) : warning C4091:
'__declspec(dllexport)' : ignored on left of 'World' when no variable is
declared

-- 
View this message in context: http://www.nabble.com/boost-python-in-visual-c%2B%2B-2008-tp23130743p23130743.html
Sent from the Python - c++-sig mailing list archive at Nabble.com.



More information about the Cplusplus-sig mailing list