Embedding Python in C, linking fails with undefined reference to `Py_Initialize'

前端 未结 5 1408
陌清茗
陌清茗 2021-02-14 02:21

I am trying to compile the example from the docs https://docs.python.org/2.7/extending/embedding.html and my code looks exactly like the one under 5.1:

#include          


        
5条回答
  •  执念已碎
    2021-02-14 02:54

    Libraries have to come after the object files when you are linking, so do:

    gcc  embedpy.o $(/usr/bin/python2.7-config --ldflags)
    

提交回复
热议问题