Results 1 to 2 of 2

Thread: Building QT Console Project with Boost Python

  1. #1
    Join Date
    Jul 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Building QT Console Project with Boost Python

    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
    Qt Code:
    1. #include <QCoreApplication>
    2.  
    3. #include <boost/python/module.hpp>
    4. #include <boost/python/def.hpp>
    5.  
    6. char const* getOutput()
    7. {
    8. return "Calling getOutput.";
    9. }
    10.  
    11. BOOST_PYTHON_MODULE(B_API_ext)
    12. {
    13. using namespace boost::python; // Ignore the emocon sb "::P"
    14. def("getOutput", getOutput);
    15. }
    16.  
    17.  
    18. // Default QT console project
    19. int main(int argc, char *argv[])
    20. {
    21. QCoreApplication a(argc, argv);
    22.  
    23. return a.exec();
    24. }
    To copy to clipboard, switch view to plain text mode 
    .Pro file setup:

    Qt Code:
    1. QT += core
    2. QT -= gui
    3.  
    4. TARGET = QCProj
    5. CONFIG += console
    6. CONFIG -= app_bundle
    7.  
    8. TEMPLATE = app
    9.  
    10. SOURCES += main.cpp
    11.  
    12. INCLUDEPATH += C:\Boost\boost_1_61_0
    13. INCLUDEPATH += C:\Python27\include
    14.  
    15. LIBS += C:\Boost\boost_1_61_0\stage\lib\libboost_python-mgw48-mt-d-1_61.a
    16. 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.
    Last edited by anda_skoa; 13th July 2016 at 11:12. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,323
    Thanks
    36
    Thanked 1,526 Times in 1,477 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Building QT Console Project with Boost Python

    LIBS directives are usually

    -L path -l libraryname

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 9th November 2012, 13:29
  2. Embedding PyQt4 into an Application running Python via Boost::Python
    By GreyHound in forum Installation and Deployment
    Replies: 1
    Last Post: 6th February 2012, 06:48
  3. boost python inside pyside
    By strattonbrazil in forum Qt Programming
    Replies: 0
    Last Post: 11th August 2011, 16:54
  4. Building Boost libraries for QT
    By nhs_0702 in forum Qt Programming
    Replies: 1
    Last Post: 1st April 2010, 09:54
  5. making qmake create VisualStudio console app project file?
    By akos.maroy in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2008, 14:45

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.