newton
06-08-2004, 09:44
Hi,
ich möchte aus einem C++ Prgramm python benutzten.
Also beispielsweise:
#include <iostream>
#include "/usr/include/python2.2/Python.h"
int main(int argc, char * argv[])
{
// initialize the interpreter
Py_Initialize();
// evaluate some code
PyRun_SimpleString("import sys\n");
//ignore line wrap on following line
PyRun_SimpleString("sys.stdout.write('Hello from an embedded Python Script\n')\n");
// shut down the interpreter
Py_Finalize();
return 0;
}
Wenn ich das jetzt kompiliere (auf Redhat 9), bekomm ich folgende Meldung:
/tmp/ccuSgVFb.o(.text+0x11): In function `main':
: undefined reference to `Py_Initialize'
/tmp/ccuSgVFb.o(.text+0x1e): In function `main':
: undefined reference to `PyRun_SimpleString'
/tmp/ccuSgVFb.o(.text+0x2e): In function `main':
: undefined reference to `PyRun_SimpleString'
/tmp/ccuSgVFb.o(.text+0x36): In function `main':
: undefined reference to `Py_Finalize'
collect2: ld returned 1 exit status
Wenn ichs richtig versteh, dann weis der compiler nichts mit den Py* funktionen anzufangen, aber eigentlich sollten die doch in Python.h definiert sein. :confused:
Weis jemand Rat/Abhilfe ?
Gruss,
newton
ich möchte aus einem C++ Prgramm python benutzten.
Also beispielsweise:
#include <iostream>
#include "/usr/include/python2.2/Python.h"
int main(int argc, char * argv[])
{
// initialize the interpreter
Py_Initialize();
// evaluate some code
PyRun_SimpleString("import sys\n");
//ignore line wrap on following line
PyRun_SimpleString("sys.stdout.write('Hello from an embedded Python Script\n')\n");
// shut down the interpreter
Py_Finalize();
return 0;
}
Wenn ich das jetzt kompiliere (auf Redhat 9), bekomm ich folgende Meldung:
/tmp/ccuSgVFb.o(.text+0x11): In function `main':
: undefined reference to `Py_Initialize'
/tmp/ccuSgVFb.o(.text+0x1e): In function `main':
: undefined reference to `PyRun_SimpleString'
/tmp/ccuSgVFb.o(.text+0x2e): In function `main':
: undefined reference to `PyRun_SimpleString'
/tmp/ccuSgVFb.o(.text+0x36): In function `main':
: undefined reference to `Py_Finalize'
collect2: ld returned 1 exit status
Wenn ichs richtig versteh, dann weis der compiler nichts mit den Py* funktionen anzufangen, aber eigentlich sollten die doch in Python.h definiert sein. :confused:
Weis jemand Rat/Abhilfe ?
Gruss,
newton