在C+中嵌入Python+;图书馆 我正在研究一些C++代码中的Python,但是我正在编译它。
对于头文件,我有在C+中嵌入Python+;图书馆 我正在研究一些C++代码中的Python,但是我正在编译它。,c++,python,linker,embedding,C++,Python,Linker,Embedding,对于头文件,我有 #include <Python.h> 但最终会得到 EmbeddedPython.cpp:1:20: error: Python.h: No such file or directory EmbeddedPython.cpp: In function ‘int main(int, char**)’: EmbeddedPython.cpp:6: error: ‘Py_Initialize’ was not declared in this scope ....
#include <Python.h>
但最终会得到
EmbeddedPython.cpp:1:20: error: Python.h: No such file or directory
EmbeddedPython.cpp: In function ‘int main(int, char**)’:
EmbeddedPython.cpp:6: error: ‘Py_Initialize’ was not declared in this scope
....
然后我试着
g++ EmbeddedPython.cpp -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
这就排除了前两个错误,但我还是以
Undefined symbols:
"_Py_Initialize", referenced from:
_main in ccxJAUAB.o
我对这有点陌生,但我觉得我学得很快。我相信我需要“链接”一个图书馆,对吗?但哪一个和如何?我需要动态的还是静态的
我正在使用MacBook Pro。您需要链接到libpython。UNIX程序员在link命令中使用“-lpython”来实现这一点(即在“g++”命令的末尾)。在Mac上,我想应该是“-framework Python”。我还有一个macbook pro、python2.5、python2.6和python2.7.got,我添加了/usr/lib/libpython.dylib,谢谢。还有什么我可以键入的,这样我就不必键入-I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5我不知道苹果的gcc对框架做了什么。如果“-frameworkpython”没有考虑到这一点,那么我认为您将被困在现有的框架中。
Undefined symbols:
"_Py_Initialize", referenced from:
_main in ccxJAUAB.o