我想用 ac 程序调用一个 python 程序,
操作系统:ubuntu 12.10 x64 python2.7.3
C代码:
#include <stdio.h>
#include <stdlib.h>
#include <python2.7/Python.h>
int main(int argc, char** argv)
{
printf("Hello world!\n");
Py_Initialize();
Py_SetProgramName("c_python");
PyRun_SimpleString("print \"Hello world,Python!\"\n");
Py_Finalize();
exit(0);
}
编译外壳:
gcc -I/usr/include/python2.7 -L/usr/lib/python2.7 -Wall -fPIC c_python.c -o c_pyton
/tmp/cciuHgrf.o:in ‘main’:
c_python.c:(.text+0x1c):reference undefined ‘Py_Initialize’
c_python.c:(.text+0x28):reference undefined ‘Py_SetProgramName’
c_python.c:(.text+0x3e):reference undefined ‘Py_Finalize’
collect2: error: ld return 1