Hi, thank you Stefan, but a have buliding error : LINK : fatal error LNK1104:
cannot open file 'boost_python-vc100-mt-1_48.lib' my first C++ program to
execute my Python script was : // ------------ main.cpp ------------
#include <Python.h>
#include <fstream>
#include <iostream>using namespace std;int main() {
int fin;
//Test d'existance du fichier
ifstream fichier("personnage.py");
if (fichier.fail()) {
cout << "Fichier de script introuvable : " << "personnage.py" <<"\n";
return 0;
}
// open python script
FILE* pyFile = fopen("personnage.py", "r");
Py_Initialize();
// Execute le script
string exec ( "execfile(r\"" ); // note r for raw Python string.
exec += "personnage.py" ; exec += "\")" ;
PyRun_SimpleString( (char*) exec.c_str() ); cin >> fin;
Py_Finalize();
return 0;
}
// -----------------------------------------
but now a have a building error with this code :
// -------------- new main -------------
#include <Python.h>
#include <fstream>
#include <iostream>
#include "../Boost_Python/personnage.h"#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <boost/python.hpp> using namespace std;
void call_script(std::string const &script, Personnage &p)
{
namespace bpl = boost::python;
bpl::dict global;
global["personnage"] = p; // inject 'p' into script's environment
bpl::exec_file(script.c_str(), global); // run it
}
int main() {
int fin;
//Test d'existance du fichier
ifstream fichier("personnage.py");
if (fichier.fail()) {
cout << "Fichier de script introuvable : " << "personnage.py" <<"\n";
return 0;
}
// Ouvre le script python a executer
FILE* pyFile = fopen("personnage.py", "r");
Personnage p("toto", 500);
Py_Initialize();
call_script("personnage.py", p); cin >> fin;
Py_Finalize();
return 0;
}My error is : LINK : fatal error LNK1104: cannot open file
'boost_python-vc100-mt-1_48.lib'I using VS2010 and have add
C:\boost_1_48_0\stage\lib\boost_python-vc100-mt-1_48.lib to the additionnal
Library Directories _______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig