Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Qt with boost
QtWS25 Last Chance

Qt with boost

Scheduled Pinned Locked Moved C++ Gurus
9 Posts 3 Posters 3.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kumararajas
    wrote on last edited by
    #1

    Hello!

    In my Qt application, I am using some of "boost" libraries.

    I have included the boost library path in pro file

    @
    INCLUDEPATH += C:\boost_1_57_0
    @

    When I build the application, I get an error:

    @
    C:\Qt\4.8.4\bin\moc.exe -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SCRIPT_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"........\Qt\4.8.4\include\QtCore" -I"........\Qt\4.8.4\include\QtNetwork" -I"........\Qt\4.8.4\include\QtGui" -I"........\Qt\4.8.4\include\QtXml" -I"........\Qt\4.8.4\include\QtScript" -I"........\Qt\4.8.4\include" -I"........\Qt\4.8.4\include\QtTest" -I"........\boost_1_57_0" -I"........\Qt\4.8.4\include\ActiveQt" -I"debug" -I"." -I"..\HMITester" -I"." -I"........\Qt\4.8.4\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\HMITester\hmitestercontrol.h -o debug\moc_hmitestercontrol.cpp
    mingw32-make.exe[1]: Leaving directory `C:/Users/suseelk/Downloads/HMITester-build-desktop-Qt_4_8_4__4_8_4__Debug'
    :/boost_1_57_0/boost/type_traits/detail/has_binary_operator.hp:50: Parse error at "BOOST_JOIN"
    mingw32-make.exe[1]: *** [debug/moc_hmitestercontrol.cpp] Error 1
    mingw32-make.exe: *** [debug] Error 2
    16:45:03: The process "C:\Qt\qtcreator-2.4.1\mingw\bin\mingw32-make.exe" exited with code 2.
    Error while building project HMITester (target: Desktop)
    When executing build step 'Make'
    @

    When I searched for the error in google, I understood that this might be bug in MOCC.

    I also saw some work around to make it work
    @
    QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc$${EXE_SUFFIX} -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED
    @

    But, this doesnt work for me still.

    Can anyone help me out?

    Many thanks!

    --Kumar

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Could you show a source code where the error is happening?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kumararajas
        wrote on last edited by
        #3

        Hi Andre,

        Error occurs while creating the moc file.

        Here is the source code:

        hmitestercontrol.h

        @
        #ifndef HMITESTERCONTROL_H
        #define HMITESTERCONTROL_H

        #include "ui_hmitestercontrol.h"
        #include "processcontrol.h"

        #include <QtGui/QMainWindow>

        class HMITesterControl : public QMainWindow
        {
        Q_OBJECT

        public:
        HMITesterControl(QWidget *parent = 0, Qt::WFlags flags = 0);
        ~HMITesterControl();

        public:
        //test suite info update
        void updateTestSuiteInfo(DataModel::TestSuite*);

        //form visualization and state
        void setForm_initState();
        void setForm_stopState();
        void setForm_playState();
        void setForm_recState();
        void setForm_pausePlayState();
        void setForm_pauseRecState();
        
        //external method to change lcd value (because threads)
        //emits a signal to launch the internal
        void setLcdValueChanged(int);
        

        private:
        Ui::HMITesterControlClass ui;

        //initialization
        void _initializeForm();
        
        //menus
        QMenu *mainMenu_;
        QMenu *fileMenu_;
        QMenu *tsuiteMenu_;
        QMenu *playTcaseMenu_;
        QMenu *deleteTcaseMenu_;
        QMenu *configMenu_;
        QMenu *speedMenu_;
        QActionGroup *playTestCaseActionGroup_;
        QActionGroup *deleteTestCaseActionGroup_;
        QActionGroup *speedActionGroup_;
        
        // overall process controller
        ProcessControl processControl_;
        

        private slots:
        //button handlers
        void tb_play_clicked();
        void tb_pause_clicked();
        void tb_stop_clicked();
        void tb_rec_clicked();
        void tb_screenshot_clicked();

        //menu actions handler
        void action_open_triggered();
        void action_new_triggered();
        void action_exit_triggered();
        void action_speed100_triggered();
        void action_speed75_triggered();
        void action_speed50_triggered();
        void action_speed25_triggered();
        void action_keepAlive_triggered(bool);
        void action_showTesterOnTop_triggered(bool);
        
        //testSuite handling
        void PlayTestCaseSelected_triggered();
        void DeleteTestCaseSelected_triggered(bool);
        
        //form visualization internal methods
        void _form_initState();
        void _form_stopState();
        void _form_playState();
        void _form_recState();
        void _form_pausePlayState();
        void _form_pauseRecState();
        
        //internal method to change lcd value (because threads)
        void _changeLcdValue(int);
        

        signals:

        ///form visualization signals
        void form_initState();
        void form_stopState();
        void form_playState();
        void form_recState();
        void form_pausePlayState();
        void form_pauseRecState();
        
        //a signal to change the lcd widget
        void changeLcdValue(int);
        

        };

        #endif // HMITESTERCONTROL_H
        @

        --Kumar

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kumararajas
          wrote on last edited by
          #4

          hmitestercontrol.cpp
          @
          #include "hmitestercontrol.h"
          #include <cassert>
          #include <iostream>
          #include "debug.h"
          #include "generalinputdialog.h"
          #include "qtutils.h"
          #include <QFile>
          #include <QTest>
          #include "ohtconfig.h"

          HMITesterControl::HMITesterControl(QWidget *parent, Qt::WFlags flags)
          : QMainWindow(parent, flags)
          {
          ui.setupUi(this);
          _initializeForm();
          }

          HMITesterControl::~HMITesterControl()
          {
          }

          /// ///
          ///
          /////initialization
          ///
          /// ///

          void HMITesterControl::_initializeForm()
          {
          ///
          /// checking libraries
          ///

          QString libpath = QtUtils::getCurrentDir();
          DEBUG(D_GUI,libpath.toStdString());
          libpath = libpath + "/libPreload/";
          if ( ! ( QFile::exists ( libpath + "libLibPreload.so.1.0.0" ) &&
                   QFile::exists ( libpath + "libLibPreload.so" ) &&
                   QFile::exists ( libpath + "libLibPreload.so.1" ) &&
                   QFile::exists ( libpath + "libLibPreload.so.1.0" ) ) )
          {
              DEBUG(D_GUI,"(HMITesterControl::initializeForm) Failed Preload Libraries checking.");
              QtUtils::newErrorDialog ( "Failed Preload Libraries checking." );
              assert ( 0 );
          }
          else
          {
              DEBUG(D_GUI,"(HMITesterControl::initializeForm) Preload Libraries checking OK.");
          }
          
          ///
          /// connecting signals and slots
          ///
          
          //buttons
          connect(ui.tb_play,SIGNAL(clicked()),this,SLOT(tb_play_clicked()));
          connect(ui.tb_pause,SIGNAL(clicked()),this,SLOT(tb_pause_clicked()));
          connect(ui.tb_stop,SIGNAL(clicked()),this,SLOT(tb_stop_clicked()));
          connect(ui.tb_rec,SIGNAL(clicked()),this,SLOT(tb_rec_clicked()));
          connect(ui.tb_screenshot,SIGNAL(clicked()),this,SLOT(tb_screenshot_clicked()));
          
          //menu
          connect(ui.action100,SIGNAL(triggered(bool)),this,SLOT(action_speed100_triggered()));
          
          connect(ui.actionShowTesterOnTop,SIGNAL(triggered(bool)),this,SLOT(action_showTesterOnTop_triggered(bool)));
          connect(ui.action_Open,SIGNAL(triggered(bool)),this,SLOT(action_open_triggered()));
          
          
          //lcd counter
          connect(this, SIGNAL(changeLcdValue(int)),
                  this, SLOT(_changeLcdValue(int)),
                  Qt::QueuedConnection);
          
          //form visualization states
          connect(this, SIGNAL(form_initState()),
                  this, SLOT(_form_initState()),
                  Qt::QueuedConnection);
          connect(this, SIGNAL(form_stopState()),
                  this, SLOT(_form_stopState()),
                  Qt::QueuedConnection);
          connect(this, SIGNAL(form_playState()),
                  this, SLOT(_form_playState()),
                  Qt::QueuedConnection);
          connect(this, SIGNAL(form_recState()),
                  this, SLOT(_form_recState()),
                  Qt::QueuedConnection);
          connect(this, SIGNAL(form_pausePlayState()),
                  this, SLOT(_form_pausePlayState()),
                  Qt::QueuedConnection);
          connect(this, SIGNAL(form_pauseRecState()),
                  this, SLOT(_form_pauseRecState()),
                  Qt::QueuedConnection);
          
          ///
          /// menu settings
          ///
          
          ///getting menus
          //file
          mainMenu_ = ui.menuBar->findChild<QMenu*> ( "menu_Main" );
          assert ( mainMenu_ );
          fileMenu_ = mainMenu_->findChild<QMenu*> ( "menu_File" );
          assert ( fileMenu_ );
          //test suite
          tsuiteMenu_ = mainMenu_->findChild<QMenu*> ( "menu_TestSuite" );
          assert ( tsuiteMenu_ );
          playTcaseMenu_ = tsuiteMenu_->findChild<QMenu*> ( "menu_Play_Test_Case" );
          assert ( playTcaseMenu_ );
          deleteTcaseMenu_ = tsuiteMenu_->findChild<QMenu*> ( "menu_Delete_Test_Case" );
          assert ( deleteTcaseMenu_ );
          playTestCaseActionGroup_ = new QActionGroup ( playTcaseMenu_ );
          deleteTestCaseActionGroup_ = new QActionGroup ( deleteTcaseMenu_ );
          //config
          configMenu_ = mainMenu_->findChild<QMenu*> ( "menu_Config" );
          assert ( configMenu_ );
          speedMenu_ = configMenu_->findChild<QMenu*> ( "menu_Speed" );
          assert ( speedMenu_ );
          speedActionGroup_ = new QActionGroup ( speedMenu_ );
          speedActionGroup_->addAction ( ui.action100 );
          speedActionGroup_->addAction ( ui.action75 );
          speedActionGroup_->addAction ( ui.action50 );
          speedActionGroup_->addAction ( ui.action25 );
          
          ///
          /// overall process controller settings
          ///
          //create and initialize
          processControl_.GUIReference(this);
          processControl_.initialize();
          //set config values
          processControl_.setContext().keepAlive = false;
          processControl_.setContext().showTesterOnTop = true;
          processControl_.setExecutionSpeed(50);
          
          ///initialize visualization
          form_initState();
          
          //check always on top
          action_showTesterOnTop_triggered(true);
          

          }

          @

          --Kumar

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kumararajas
            wrote on last edited by
            #5

            (Note: I dont claim this as "my" Qt application. This is a test application got from gitorious.)

            Please let me know if you need any more information.

            Thanks.

            --Kumar

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              IIRC there was a workaround for that, something like

              @
              #ifndef Q_MOC_RUN
              #include <boost/your_boost_header.hpp>
              #endif // Q_MOC_RUN
              @

              Hope it helps

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You should only need that in files which contain classes that are going to be moc'd.

                Looks like you are missing

                @LIBS += -LC:/path/to/boos/libraries@

                In your pro file

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  kumararajas
                  wrote on last edited by
                  #8

                  Sam,

                  I did the same

                  @
                  LIBS += -LC:\boost_1_57_0 -lboost_thread-mt
                  -lboost_serialization-mt
                  @

                  Here the problem is, I dont have "built" libraries in the package.

                  --Kumar

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Well, then you'll have to build them yourself, IIRC, you should have a readme file explaining how to do it.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved