Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
710 views
in Technique[技术] by (71.8m points)

python - 从C调用python时出现分段错误(核心已转储)(Segmentation fault (core dumped) when calling python from C [closed])

I am inexperience in Python and C programs.

(我对Python和C程序缺乏经验。)

My test script written in c/c++ needs to call a python function.

(我用c / c ++编写的测试脚本需要调用python函数。)

I have searched online [ https://www.codeproject.com/Articles/11805/Embedding-Python-in-CC-Part-I] , then copied the "call_function.c" and "py_function.py" from the link into my Linux system.

(我已经在线搜索[ https://www.codeproject.com/Articles/11805/Embedding-Python-in-CC-Part-I] ,然后将链接中的“ call_function.c”和“ py_function.py”复制到我的Linux系统。)

The Linux version is "3.13.0-65-generic" and was installed Python2.7.

(Linux版本是“ 3.13.0-65-generic”,并已安装Python2.7。)

There was not error when compiling "call_function.c" with below command line.

(使用以下命令行编译“ call_function.c”时没有错误。)

[gcc call_function.c -o call_function -I/usr/include/python2.7 -L/usr/lib/python2.7/lib -lpython2.7]

([gcc call_function.c -o call_function -I / usr / include / python2.7 -L / usr / lib / python2.7 / lib -lpython2.7])

I then ran the "call_function" with below command.

(然后,我使用以下命令运行“ call_function”。)

[./call_function py_function.py multiply]

([./call_function py_function.py乘以])

The "Segmentation fault (core dumped)" popped up.

(弹出“分段故障(核心已转储)”。)

I do not have any clues on this error.

(我对此错误没有任何线索。)

Please enlighten me.

(请赐教。)

  ask by user10293779 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...