Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt + GCC 4.9 Macports + openmp (MAC - Mavericks)

    Installation and Deployment
    3
    15
    9754
    Loading More Posts
    • 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.
    • N
      Neogene last edited by

      Hi all,

      if someone could help me because it's the first time i'm using Qt and i'm trying to configure Qt to use in a OpenCV project which uses also openmp, i want to use this tool to develop a cross platform GUI .

      step 1) To use OpenMP on Mavericks i used macports which installed GCC 4.9 (gdb too) into /opt/local/bin /lib /inlcude

      step 2)I downloaded and installed QT, it installed the Kit with QT 5.2.1 clang 64 bit.

      step 3) i added the -fopenmp to the compiler and the linker

      The .pro file is the following:

      TEMPLATE = app
      CONFIG += console
      CONFIG -= app_bundle
      CONFIG -= qt
      INCLUDEPATH += /opt/local/lib
      QMAKE_CXXFLAGS += -fopenmp
      QMAKE_LFLAGS += -fopenmp
      QMAKE_CXXFLAGS+=-std=c++11
      SOURCES += main.cpp

      step 4) I created a Manual Compiler configuration in the Compilers tab, which points to /opt/local/bin/g++-mp-4.9 and a Debuggers configuration too which points to /opt/local/bin/ggdb.

      step 5) i created in the Manual kit tab a custom one:

      Device type: Desktop
      Device: Local PC
      Sysroot: empty
      Compiler: GCC 4.9 (the one created manually inside the Compilers tab)
      Debugger: GGDB (the one created manually inside the Devuggers tab)
      QT version: the only available seems to be Qt 5.2.1 clang 64bit

      ERROR 1: There is a red alert icon next to the Kits i created which disappears when i turn off the Qt version setting it to None (but i need to use it).

      ERROR 2: compile output:

      @Starting: "/opt/local/bin/gmake"
      /Applications/Xcode.app/Contents/Developer/usr/bin/g++ -c -pipe -fopenmp -std=c++11 -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -Wall -W -fPIE -I../../../../Qt/5.2.1/clang_64/mkspecs/macx-g++ -I../OpenCV1 -I/opt/local/lib -I. -o main.o ../OpenCV1/main.cpp
      @

      Seems that even if i configured to use the g++ inside the opt/ folder it is not used and the Xcode one is always used.

      Build Steps about qmake:

      @qmake /Users/Neogene/Documents/Lavori/QT/OpenCV1/OpenCV1.pro -r -spec macx-g++ CONFIG+=debug CONFIG+=x86@

      Make: Override /usr/bin/make: /opt/local/bin/gmake

      ERROR 3: the autocomplete exposes the correct path of the #include <omp.h> but when compiling it doesn't find the omp.h file, maybe this is due the the wrong compiler used (the Xcode one vs the GCC macports one)

      #include <iostream>
      #include <omp.h>

      using namespace std;

      int main()
      {
      cout << "Hello World QT!" << endl;
      return 0;
      }

      Somebody could tell me why? thank you in advance.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        Because Qt is configured to use the mkspec for clang. If you want to use another one you will need to tell it by hand

        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 Reply Quote 0
        • N
          Neogene last edited by

          Im' trying to compile the QT by scratch using the gcc flag but it fails, i'm hoping to find a solution.

          [quote author="SGaist" date="1399236303"]Hi and welcome to devnet,

          Because Qt is configured to use the mkspec for clang. If you want to use another one you will need to tell it by hand[/quote]

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Can you post the errors you are getting ?

            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 Reply Quote 0
            • N
              Neogene last edited by

              sudo ./configure -platform macx-g++42 -qt-xcb

              note: the -qt-xcb is due to the error: _
              The test for linking against libxcb and support libraries failed! You might need to install dependency packages, or pass -qt-xcb._

              gives a couple of

              xcrun: error: unable to find utility "g++-4.2", not a developer tool or in PATH

              sending command: g++ --version
              g++ (MacPorts gcc49 4.9-20140416_0) 4.9.0 20140416 (prerelease)

              sending command: gcc --version
              gcc (MacPorts gcc49 4.9-20140416_0) 4.9.0 20140416 (prerelease)

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                Never use sudo for this kind of task

                You don't have g++4.2 but 4.9, you need to create your own mkspec for 4.9. You can copy the 4.2 and update it's content to use your macport gcc.

                Since you're running OS X, xcb doesn't make sense. Let the default value to start

                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 Reply Quote 0
                • N
                  Neogene last edited by

                  Ok, i duplicated the macx-g++42 to macx-g++49, edited the quake.conf setting

                  QMAKE_CC = gcc-mp-4.9
                  QMAKE_CXX = g++-mp-4.9

                  Next error is:

                  Creating qmake...
                  /opt/local/bin/g++-mp-4.9 -c -o qlibraryinfo.o -pipe -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -g -gdwarf-2 -fconstant-cfstrings -g -DQMAKE_OPENSOURCE_EDITION -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/library -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/generators -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/generators/unix -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/generators/win32 -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/generators/mac -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/generators/integrity -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/include -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/include/QtCore -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/include/QtCore/5.2.1 -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/include/QtCore/5.2.1/QtCore -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/src/corelib/global -DHAVE_QCONFIG_CPP -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/mkspecs/macx-g++49 -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/tools/shared -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY /Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/src/corelib/global/qlibraryinfo.cpp

                  g++-mp-4.9: error: unrecognized command line option '-fconstant-cfstrings'
                  Makefile:255: set di istruzioni per l'obiettivo "qlibraryinfo.o" non riuscito

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    Right, because macx-g++ is for Apple's gcc, check the Darwin mkspec

                    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 Reply Quote 0
                    • N
                      Neogene last edited by

                      Mmmmm next one:

                      switching to darwin-g++ mkspec i had to modify the qmake.conf

                      1. adding the flag QMAKE_MAC_SDK = macosx
                      2. replcaing the cc/c++ values to gcc-mp-49 and g++-mp-4.9,

                      the error now is due to the fact that -mmacosx-version-min= isn't filled with the correct value (third row of next log)

                      /opt/local/bin/g++-mp-4.9 -c -o qlibraryinfo.o -pipe -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk *-mmacosx-version-min= *-fconstant-cfstrings -g -DQMAKE_OPENSOURCE_EDITION -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/library -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/generators -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/generators/unix -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/generators/win32 -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/generators/mac -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/qmake/generators/integrity -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/include -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/include/QtCore -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/include/QtCore/5.2.1 -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/include/QtCore/5.2.1/QtCore -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/src/corelib/global -DHAVE_QCONFIG_CPP -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/mkspecs/darwin-g++ -I/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/tools/shared -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY /Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/src/corelib/global/qlibraryinfo.cpp
                      g++-mp-4.9: error: missing argument to '-mmacosx-version-min='

                      1 Reply Last reply Reply Quote 0
                      • SGaist
                        SGaist Lifetime Qt Champion last edited by

                        Probably missing: QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6

                        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 Reply Quote 0
                        • N
                          Neogene last edited by

                          Yes works but it reaches the same error before:

                          g++-mp-4.9: error: unrecognized command line option '-fconstant-cfstrings'

                          1 Reply Last reply Reply Quote 0
                          • SGaist
                            SGaist Lifetime Qt Champion last edited by

                            Then you need to comment the lines containing that in features/qt_module.prf

                            Beware that you are entering unsupported territory. Qt for OS X is tested only with Apple's compilers.

                            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 Reply Quote 0
                            • N
                              Neogene last edited by

                              I'ts a pity cause this make quite hard to use openmp and qt on mac.

                              I removed the macx-g++ {
                              QMAKE_CFLAGS += -fconstant-cfstrings
                              QMAKE_CXXFLAGS += -fconstant-cfstrings
                              }

                              block from the qt_module.prf but running again the ./configure doesn't seem to know this change.

                              /opt/local/bin/g++-mp-4.9 -c -o qlibraryinfo.o -pipe -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -fconstant-cfstrings -g -DQMAKE_OPENSOURCE_EDITION....

                              I modified instead the configure script commenting the following line
                              #echo "CARBON_CFLAGS =-fconstant-cfstrings" >>"$mkfile"

                              after calling ./configure again it sticks to

                              In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/Availability.h:148:0,
                              from ../../include/QtCore/../../src/corelib/global/qsystemdetection.h:212,
                              from ../../include/QtCore/qsystemdetection.h:1,
                              from ../../include/QtCore/../../src/corelib/global/qglobal.h:69,
                              from ../../include/QtCore/qglobal.h:1,
                              from ../../include/QtCore/../../src/corelib/tools/qchar.h:45,
                              from ../../include/QtCore/qchar.h:1,
                              from ../../include/QtCore/../../src/corelib/tools/qstring.h:45,
                              from ../../include/QtCore/qstring.h:1,
                              from tools/qlocale_p.h:56,
                              from tools/qlocale_mac.mm:42:
                              /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:16:45: error: expected '}' before 'attribute'
                              NSUserNotificationActivationTypeReplied NS_AVAILABLE(10_9, NA) = 3
                              ^
                              In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:161:0,
                              from ../../include/QtCore/5.2.1/QtCore/private/../../../../../src/corelib/kernel/qcore_mac_p.h:73,
                              from ../../include/QtCore/5.2.1/QtCore/private/qcore_mac_p.h:1,
                              from tools/qlocale_mac.mm:49:
                              /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:16:68: error: expected unqualified-id before '=' token
                              NSUserNotificationActivationTypeReplied NS_AVAILABLE(10_9, NA) = 3
                              ^
                              /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:17:1: error: expected declaration before '}' token
                              } NS_ENUM_AVAILABLE(10_8, NA);
                              ^
                              Makefile:1827: set di istruzioni per l'obiettivo ".obj/qlocale_mac.o" non riuscito
                              gmake[3]: *** [.obj/qlocale_mac.o] Errore 1
                              gmake[3]: uscita dalla directory "/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/src/corelib"
                              Makefile:131: set di istruzioni per l'obiettivo "sub-corelib-make_first" non riuscito
                              gmake[2]: *** [sub-corelib-make_first] Errore 2
                              gmake[2]: uscita dalla directory "/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase/src"
                              Makefile:41: set di istruzioni per l'obiettivo "sub-src-make_first" non riuscito
                              gmake[1]: *** [sub-src-make_first] Errore 2
                              gmake[1]: uscita dalla directory "/Users/Neogene/Downloads/Safari/qt-everywhere-opensource-src-5.2.1/qtbase"
                              Makefile:60: set di istruzioni per l'obiettivo "module-qtbase-make_first" non riuscito
                              gmake: *** [module-qtbase-make_first] Errore 2

                              1 Reply Last reply Reply Quote 0
                              • SGaist
                                SGaist Lifetime Qt Champion last edited by

                                Did you completely clean before calling configure again ?

                                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 Reply Quote 0
                                • C
                                  CamelFrog last edited by

                                  Hi,

                                  I also would like to use openmp with qt on mac, Yosemite 10.10. Did you manage to solve your issue with GCC 4.9 or any other compiler?

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post