Results 1 to 7 of 7

Thread: Hiding boost headers from MOC, but still error

  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Hiding boost headers from MOC, but still error

    I've made fresh install of Qt 5.1.0 on Windows 7. I'm trying to compile my project which is using boost library interprocess communication. Since it was giving compilation error earlier, I've made the moc not to detect boost headers by adding #ifndef Q_MOC_RUN & #endif between the boost headers. It worked fine then.

    Now had to change my PC, installed fresh copy of Windows 7, then installed Qt 5.1.0 MSVC 2010. After building the project the same error which used occur earlier for not adding #ifndef Q_MOC_RUN surfaced again. But now I'm adding that around boost headers.

    Qt Code:
    1. D:\boost_1_53_0\boost\mpl\if.hpp:131: error: Macro argument mismatch.
    To copy to clipboard, switch view to plain text mode 

    And on clicking the reported issue - the code it pointed is
    Qt Code:
    1. // if.hpp
    2. struct if_
    3. {
    4. enum { msvc_wknd_ = BOOST_MPL_AUX_MSVC_VALUE_WKND(C_)::value };
    5.  
    6. typedef typename aux::if_impl< BOOST_MPL_AUX_STATIC_CAST(bool, msvc_wknd_) >
    7. ::template result_<T1,T2>::type type;
    8.  
    9. BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C_,T1,T2))
    10. };
    11.  
    12. #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
    13.  
    14. BOOST_MPL_AUX_NA_SPEC(3, if_) // <<------------------- Here
    15.  
    16. }}
    To copy to clipboard, switch view to plain text mode 

    Someone please help me. It's affecting my tight schedule by not allowing me to proceed further.
    And my project settings looks like as shown in the attached pic.

    settings.jpg

    Thank you.
    Last edited by rawfool; 11th July 2013 at 15:56.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Hiding boost headers from MOC, but still error

    I am assuming that moc is producing that message when faced with your source code. The specified Boost 1.53 include, for example, runs through Qt 5.1.0 moc without error and without special measures (and later compiles without error):
    Qt Code:
    1. #include <QCoreApplication>
    2. #include <boost/mpl/if.hpp>
    3.  
    4. class Test:public QObject
    5. {
    6. Q_OBJECT
    7. public:
    8. Test(QObject *p = 0): QObject(p) { }
    9. signals:
    10. void stuff();
    11. };
    12.  
    13. int main(int argc, char **argv)
    14. {
    15. QCoreApplication app(argc, argv);
    16. return 0;
    17. }
    18. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    So, the question becomes, what else are you including and in what order.
    Did you build you own Qt with the MSVC 2010 compiler? If so, did you install the required Microsoft patches in the required order first?

  3. #3
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Hiding boost headers from MOC, but still error

    I've not included #include <boost/mpl/if.hpp>
    The headers I included are
    Qt Code:
    1. #ifndef Q_MOC_RUN
    2. #include <boost/interprocess/managed_windows_shared_memory.hpp>
    3. #include <boost/interprocess/managed_shared_memory.hpp>
    4. #include <boost/interprocess/sync/interprocess_mutex.hpp>
    5. #include <boost/interprocess/sync/scoped_lock.hpp>
    6. #include <boost/interprocess/allocators/allocator.hpp>
    7. #include <boost/interprocess/containers/map.hpp>
    8. #include <boost/interprocess/containers/string.hpp>
    9. #endif // Q_MOC_RUN
    10.  
    11. using namespace boost::interprocess;
    12.  
    13. // Types
    14. typedef managed_shared_memory::segment_manager segment_manager_t;
    15. typedef boost::interprocess::allocator<void, segment_manager_t> void_allocator;
    16. typedef boost::interprocess::allocator<char, segment_manager_t> char_allocator;
    17. typedef boost::interprocess::basic_string<char, std::char_traits<char>, char_allocator> char_string;
    18. typedef std::pair<const size_t, char_string> size_t_string_map_value_type;
    19. typedef std::pair<size_t, char_string> movable_to_size_t_string_map_value_type;
    20. typedef boost::interprocess::allocator<size_t_string_map_value_type, segment_manager_t> size_t_string_map_value_type_allocator;
    21. typedef boost::interprocess::map<size_t, char_string, std::less<size_t>, size_t_string_map_value_type_allocator> size_t_string_map_type;
    22. typedef std::pair<const char_string, char_string> string_string_map_value_type;
    23. typedef std::pair<char_string, char_string> movable_to_string_string_map_value_type;
    24. typedef boost::interprocess::allocator<string_string_map_value_type, segment_manager_t> string_string_map_value_type_allocator;
    25. typedef boost::interprocess::map<char_string, char_string, std::less<char_string>, string_string_map_value_type_allocator> string_string_map_type;
    26. typedef std::pair<const char_string, bool> string_bool_map_value_type;
    27. typedef std::pair<char_string, bool> movable_to_string_bool_map_value_type;
    28. typedef boost::interprocess::allocator<string_bool_map_value_type, segment_manager_t> string_bool_map_value_type_allocator;
    29. typedef boost::interprocess::map<char_string, bool, std::less<char_string>, string_bool_map_value_type_allocator> string_bool_map_type;
    30.  
    31. class CWorker : public QObject
    32. {
    33. Q_OBJECT
    34. // my class members
    35. };
    To copy to clipboard, switch view to plain text mode 

    Did you build you own Qt with the MSVC 2010 compiler?
    No, I've downloaded qt-windows-opensource-5.1.0-msvc2010-x86-offline.exe. Later installed Windows SDK, to get MSVC 2010 compiler.

    In this link someone posted same problem and mentioned 4.8.4 is not having this problem. If Qt 4.8 does not have any issues, then are there any dependencies to go back from Qt 5.0.2/5.1 ??

    Thank you.
    Last edited by rawfool; 12th July 2013 at 06:21.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Hiding boost headers from MOC, but still error

    You have included if.hpp indirectly... that is where the error is being reported. It may be triggered by something processed before that.
    The header Tannin was having problems with in the thread you linked also passes moc cleanly in its 1.53 incarnation.

    Your collection of headers and typedefs run through moc cleanly when dropped into my test code above.
    I used the official 5.1 MingW build but since you are not getting as far as the compiler the MingW vs MSVC difference is irrelevant.
    I suggest you check that you are running qmake/moc from the Qt version you think you are.

    If you want to go back to Qt 4.8.5 then there may be changes you need to make to your source. Unfortunately my crystal ball is away for servicing.
    Last edited by ChrisW67; 12th July 2013 at 08:38.

  5. #5
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Hiding boost headers from MOC, but still error

    Let me in explain steps what I've done, pls help me with this.
    1. Installed a Windows 7 freshly on my machine
    2. Then installed .NET 4 Framework
    3. Then installed Windows SDK 7.1 with all the options checked
    4. Installed Qt 5.0.2 MSVC 2010 x86
    5. Downloaded boost 1.53 & got libboost_date_time-vc100-mt-1_53.lib & libboost_date_time-vc100-mt-gd-1_53.lib from my peer who compiled the same. Using only date_time because I'm using boost shared memory only.
    6. Added "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin" to system environment variables path. Don't know if I have to do this, but just added to make sure that cl.exe is in environment variables path.
    7. Compiling project gives D:\boost_1_53_0\boost\mpl\if.hpp:131: error: Macro argument mismatch.

    My .pro file is
    Qt Code:
    1. QT += core gui network xml
    2. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    3. TARGET = BrainyAssUI
    4. TEMPLATE = app
    5. SOURCES += main.cpp\
    6. .. source files
    7.  
    8. HEADERS += ... headerfiles
    9.  
    10. RESOURCES += \
    11. addons.qrc
    12.  
    13. INCLUDEPATH += D:/boost_1_53_0\
    14. D:/svn/UtilityParser/include\
    15. D:/svn/vtd-xml
    16.  
    17. QMAKE_CXXFLAGS += /FI"customTypes.h"
    18. QMAKE_CXXFLAGS += /DNOMINMAX
    19.  
    20. LIBS += -L"D:/boost_lib"\
    21. -llibboost_date_time-vc100-mt-1_53
    22. -lole32\
    23. -loleaut32\
    24. -L"D:/svn/UtilityParser/Release"\
    25. -lUtilityParser\
    26. -lvtd-xml
    To copy to clipboard, switch view to plain text mode 

    My boost lib files are in D:\boost_lib
    And boost include folder is D:\boost_1_53_0

    Added #ifndef Q_MOC_RUN to the boost headers to hide from MOC
    Qt Code:
    1. #ifndef Q_MOC_RUN
    2. #include <boost/mpl/if.hpp>
    3. #include <boost/interprocess/managed_windows_shared_memory.hpp>
    4. #include <boost/interprocess/managed_shared_memory.hpp>
    5. #include <boost/interprocess/sync/interprocess_mutex.hpp>
    6. #include <boost/interprocess/sync/scoped_lock.hpp>
    7. #include <boost/interprocess/allocators/allocator.hpp>
    8. #include <boost/interprocess/containers/map.hpp>
    9. #include <boost/interprocess/containers/string.hpp>
    10. #endif // Q_MOC_RUN
    To copy to clipboard, switch view to plain text mode 

    So finally the error I get - D:\boost_1_53_0\boost\mpl\if.hpp:131: error: Macro argument mismatch.
    Kindly help me tackle this issue.

    Adding more info (this is not directly related to Qt, but boost. Still explaining it as this might give more insight into my problem help you understand where I'm doing wrong.)

    Tried to compile boost using command line option that comes with Qt 5.0.2 MSVC 2010. When I try to build boost (run bootstrap.bat \tools\v2\) it says -
    Qt Code:
    1. cl.exe - System Error
    2. The program can't start because mspdb100.dll is missing from your computer. Try reinstalling the program to fix this problem.
    To copy to clipboard, switch view to plain text mode 

    Screenshot of my Tools > Options > Build & Run > Compilers
    build_options.PNG

    Screenshot of my installed programs (this might give clear picture if I've installed required tools to build my project)
    installed programs.PNG
    Last edited by rawfool; 17th July 2013 at 16:19.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Hiding boost headers from MOC, but still error

    Put this code in a file main.cpp:
    Qt Code:
    1. #include <QCoreApplication>
    2.  
    3. // Begin: Your headers exactly as given to us
    4. #ifndef Q_MOC_RUN
    5. #include <boost/interprocess/managed_windows_shared_memory.hpp>
    6. #include <boost/interprocess/managed_shared_memory.hpp>
    7. #include <boost/interprocess/sync/interprocess_mutex.hpp>
    8. #include <boost/interprocess/sync/scoped_lock.hpp>
    9. #include <boost/interprocess/allocators/allocator.hpp>
    10. #include <boost/interprocess/containers/map.hpp>
    11. #include <boost/interprocess/containers/string.hpp>
    12. #endif // Q_MOC_RUN
    13.  
    14. using namespace boost::interprocess;
    15.  
    16. // Types
    17. typedef managed_shared_memory::segment_manager segment_manager_t;
    18. typedef boost::interprocess::allocator<void, segment_manager_t> void_allocator;
    19. typedef boost::interprocess::allocator<char, segment_manager_t> char_allocator;
    20. typedef boost::interprocess::basic_string<char, std::char_traits<char>, char_allocator> char_string;
    21. typedef std::pair<const size_t, char_string> size_t_string_map_value_type;
    22. typedef std::pair<size_t, char_string> movable_to_size_t_string_map_value_type;
    23. typedef boost::interprocess::allocator<size_t_string_map_value_type, segment_manager_t> size_t_string_map_value_type_allocator;
    24. typedef boost::interprocess::map<size_t, char_string, std::less<size_t>, size_t_string_map_value_type_allocator> size_t_string_map_type;
    25. typedef std::pair<const char_string, char_string> string_string_map_value_type;
    26. typedef std::pair<char_string, char_string> movable_to_string_string_map_value_type;
    27. typedef boost::interprocess::allocator<string_string_map_value_type, segment_manager_t> string_string_map_value_type_allocator;
    28. typedef boost::interprocess::map<char_string, char_string, std::less<char_string>, string_string_map_value_type_allocator> string_string_map_type;
    29. typedef std::pair<const char_string, bool> string_bool_map_value_type;
    30. typedef std::pair<char_string, bool> movable_to_string_bool_map_value_type;
    31. typedef boost::interprocess::allocator<string_bool_map_value_type, segment_manager_t> string_bool_map_value_type_allocator;
    32. typedef boost::interprocess::map<char_string, bool, std::less<char_string>, string_bool_map_value_type_allocator> string_bool_map_type;
    33.  
    34. class CWorker : public QObject
    35. {
    36. Q_OBJECT
    37. // my class members
    38. };
    39.  
    40. // End: Your headers exactly as given to us
    41.  
    42. int main(int argc, char **argv)
    43. {
    44. QCoreApplication app(argc, argv);
    45. return 0;
    46. }
    47. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 
    with this project file:
    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (3.0) Thu Jul 18 14:08:58 2013
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. TARGET = test
    7. INCLUDEPATH += "D:/boost_1_53_0"
    8.  
    9. # Input
    10. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 

    Does it compile cleanly? If so then the problem is elsewhere, possibly in the customTypes.h header you are force-including into every single file rather than doing it explicitly where it's needed (i.e. properly).

  7. The following user says thank you to ChrisW67 for this useful post:

    rawfool (18th July 2013)

  8. #7
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Hiding boost headers from MOC, but still error

    Thank you very much ChrisW67. I was including a header for the dll which I didn't know that it was using boost. Pushing that include into #ifndef Q_MOC solved the problem.

    Does it compile cleanly? If so then the problem is elsewhere, ..
    The code which you posted above compiled cleanly and your answer made me re look at the libraries & check if they are using boost.
    Thank you very much.
    Last edited by rawfool; 18th July 2013 at 11:55.

Similar Threads

  1. Boost: use it with Qt
    By Handi in forum Installation and Deployment
    Replies: 12
    Last Post: 2nd April 2012, 00:16
  2. QT/C++/ BOOST questions
    By joebats72 in forum Newbie
    Replies: 4
    Last Post: 17th January 2011, 22:49
  3. Qt and Boost in the same C++ program?
    By TriKri in forum Qt Programming
    Replies: 12
    Last Post: 9th May 2010, 22:58
  4. Boost libraries
    By steg90 in forum General Programming
    Replies: 26
    Last Post: 13th June 2007, 12:50
  5. Error compiling Qt3 app with Boost signals support
    By stodge in forum Qt Programming
    Replies: 3
    Last Post: 3rd May 2007, 10:48

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.