PDA

View Full Version : Building QT Console Project with Boost Python



PTVSnap
12th July 2016, 15:30
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[])
{
QCoreApplication a(argc, argv);

return a.exec();
}

.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


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.

anda_skoa
13th July 2016, 11:13
LIBS directives are usually

-L path -l libraryname

Cheers,
_