Hello,
I am trying to use Boost Python inside a QT Console C project. The goal is to use external Python scripts to call some of the functions inside QT project. I am getting alot of build errors. Here are the code
main.cpp
#include <QCoreApplication>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
char const* getOutput()
{
return "Calling getOutput.";
}
BOOST_PYTHON_MODULE(B_API_ext)
{
using namespace boost::python; // Ignore the emocon sb "::P"
def("getOutput", getOutput);
}
// Default QT console project
int main(int argc, char *argv[])
{
return a.exec();
}
#include <QCoreApplication>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
char const* getOutput()
{
return "Calling getOutput.";
}
BOOST_PYTHON_MODULE(B_API_ext)
{
using namespace boost::python; // Ignore the emocon sb "::P"
def("getOutput", getOutput);
}
// Default QT console project
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
To copy to clipboard, switch view to plain text mode
.Pro file setup:
QT += core
QT -= gui
TARGET = QCProj
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:\Boost\boost_1_61_0
INCLUDEPATH += C:\Python27\include
LIBS += C:\Boost\boost_1_61_0\stage\lib\libboost_python-mgw48-mt-d-1_61.a
LIBS += C:\Boost\boost_1_61_0\stage\lib\libboost_python-mgw48-mt-1_61.a
QT += core
QT -= gui
TARGET = QCProj
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:\Boost\boost_1_61_0
INCLUDEPATH += C:\Python27\include
LIBS += C:\Boost\boost_1_61_0\stage\lib\libboost_python-mgw48-mt-d-1_61.a
LIBS += C:\Boost\boost_1_61_0\stage\lib\libboost_python-mgw48-mt-1_61.a
To copy to clipboard, switch view to plain text mode
While the example provided from Boost shows this method to export standalone C function or C++ classes as Python DLL, is there a way to do the same within a QT project environment?
Thanks in advance for your answers.
Bookmarks