C调用Python时混合编译 错误 提示:undefined reference to `Py_Initialize'

MrDarcy1 2017-06-28 12:07:20
linux下C调用python 编译出错

#include "/usr/local/include/python3.6m/Python.h"
int main(int argc, char** argv){
Py_Initialize();
PyRun_SimpleString("print 'hello python'");
Py_Finalize();
exit(0);
}

编译指令 gcc -I/usr/include -L/usr/local/lib -lpython3.6m python.c
提示:/tmp/ccYoHGsy.o: In function `main':
python.c:(.text+0xa): undefined reference to `Py_Initialize'
python.c:(.text+0x1e): undefined reference to `PyRun_SimpleStringFlags'
python.c:(.text+0x23): undefined reference to `Py_Finalize'
collect2: ld 返回 1

在usr/local/lib 中有libpython3.6m.a 文件 求问如何解决!
...全文
3426 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
LubinLew 2017-06-28
  • 打赏
  • 举报
回复 3
编译时加上python库连接

gcc -g -Wall xxx.c -lpython3.6m
MrDarcy1 2017-06-28
  • 打赏
  • 举报
回复
有人嘛 求助

23,216

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧