我想将Python解释器3.4嵌入到一个Qt 5.2.1应用程序(64位)中。 然而,我在构建时遇到了问题。我的意思是,当我在main.cpp中包含Python头文件时,它可以编译成功。
#include <python.h>
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
但当我将它放在任何其他地方(Qt头文件后面)时
//
// embedpytest.cpp
//
#include <QLibrary>
#include <python.h>
EmbedPyTest::EmbedPyTest()
{
}
我遇到编译错误:
C:\Python34\include\object.h:435: error: C2059: syntax error : ';'
C:\Python34\include\object.h:435: error: C2238: unexpected token(s) preceding ';'
这个问题与这个非常相似,但是解决方案并不起作用。
有人知道如何解决这个问题吗?或者建议一些干净的解决方法,使python.h和Qt5能够快乐地生活在一起?