如何在QT(C / C ++)中包含python.h

时间:2017-05-23 04:37:16

标签: python c++ python-2.7 qt qt-creator

  

INCLUDEPATH = -L /usr/include/python2.7

     

LIBS + = /usr/local/lib/python2.7

     

QMAKE_CXXFLAGS + = /usr/local/lib/python2.7

error: cannot find /usr/local/lib/python2.7: File format not recognized

有一个问题。 我已经安装了python-all-dev。

1 个答案:

答案 0 :(得分:2)

您必须使用以下格式:

LIBS += -L {path of your library.so} -l{library}    
INCLUDEPATH += {path of your headers} 
DEPENDPATH += {path of your headers} 

在你的情况下:

LIBS += -L /usr/local/lib/python2.7 -lpython2.7

INCLUDEPATH += /usr/include/python2.7
DEPENDPATH += /usr/include/python2.7