Estoy usando la biblioteca de Boost Python para crear extensiones de Python en mi código de C++. Me gustaría ser capaz de invocar la función de Python 'saludar' a partir del código C++ se muestra a continuación:building boost Ejemplos de python usando Visual Studio 2008
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
char const* greet()
{
return "hello, world";
}
BOOST_PYTHON_MODULE(hello_ext)
{
using namespace boost::python;
def("greet", greet);
}
Y el código Python:
import hello_ext
print hello_ext.greet()
He conseguido hacer esto utilizando el bjam (hello_ext.pyd se genera y funciona bien), pero ahora me gustaría construirlo usando Visual Studio 2008. Se construye un hello.dll (pero ni hello_ext.dll ni ningún .pyd). Después de invocar mi código python, aparece un error:
ImportError: Ningún módulo llamado hello_ext.
Después de cambiar el nombre del hello.dll a hello.pyd o hello_ext.pyd, consigo otro ImportError: cargar la DLL no
¿Cómo puedo crear el archivo .pyd correcta utilizando VS 2008?
Para aquellos interesados en la construcción de un proyecto de este tipo con un makefile (y gcc), ver http://stackoverflow.com/questions/2003506/how-to-build-a-boost-dependent-project-using-regular-makefiles/2055958#2055958 – rafak