Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator and GCC 4.6 on Mac
Forum Updated to NodeBB v4.3 + New Features

Qt Creator and GCC 4.6 on Mac

Scheduled Pinned Locked Moved Qt Creator and other tools
14 Posts 5 Posters 11.4k Views 1 Watching
  • 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.
  • O Offline
    O Offline
    objectref
    wrote on last edited by
    #1

    Hi to all!

    As Apple is now concentrating on LLVM/Clang and i don't know if will ever update it's tools with a newer GCC version, i installed it myself using macports. So, i have a valid GCC 4.6 installation on /opt/local/bin.
    I added it to Qt Creator (through Build and Run/Toolchains menu), selected it as project tool chain and it seems to compile things just fine. Unless, i use some C++ 11 feature that is indeed supported by this version of GCC, like the "auto" keyword.

    By using the command line of g++-mp-4.6, a project with C++ 11 features compile juts fine, if of course, i add the "-std=c++11" switch to the compiler.

    It seems that i cannot make Qt Creator (latest version on Qt 4.8.0) "understand" it and compile correctly. I have put that "QMAKE_CXXFLAGS += -std=c++11" (or QMAKE_CXXFLAGS += -std=c++0x) in the .pro file and then i get:

    "error: [main.o] Error 1"

    when compiling.

    I also tried to pass it as a Qmake argument with no luck.

    What am i doing wrong with this ?

    Thanks a lot for any help.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      Do you have the full output? The line you gave just points to the linker but does not provide any useful information what it might be complaining about.

      1 Reply Last reply
      0
      • O Offline
        O Offline
        objectref
        wrote on last edited by
        #3

        Thanks for the reply!

        My mac is at home and when i get back (at the afternoon) i will post back all the output needed.

        1 Reply Last reply
        0
        • O Offline
          O Offline
          objectref
          wrote on last edited by
          #4

          Ok, the Compiler Output is this:


          22:36:22: Running build steps for project eSTL1...
          22:36:22: Configuration unchanged, skipping qmake step.
          22:36:23: Starting: "/usr/bin/make" -w
          make: Entering directory /Users/objectref/Projects/tests/C++/eSTL1-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Debug' g++ -c -pipe -std=c++0x -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -I../../../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/macx-g++ -I../eSTL1 -I../eSTL1 -I. -o main.o ../eSTL1/main.cpp cc1plus: error: unrecognized command line option "-std=c++0x" make: *** [main.o] Error 1 make: Leaving directory /Users/objectref/Projects/tests/C++/eSTL1-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Debug'
          22:36:23: The process "/usr/bin/make" exited with code 2.
          Error while building project eSTL1 (target: Desktop)
          When executing build step 'Make'

          I understand that["cc1plus: error: unrecognized command line option "-std=c++0x"] is the error but the same command option is working fine under command line.

          I am sure i am missing something obvious here...

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tobias.hunger
            wrote on last edited by
            #5

            It might be using the wrong g++ then. Can you please check the PATH in Projects->Build Settings, Build Environment?

            1 Reply Last reply
            0
            • O Offline
              O Offline
              objectref
              wrote on last edited by
              #6

              Xmmm...it says: "/opt/local/bin:/Users/objectref/QtSDK/Desktop/Qt/4.8.0/gcc/bin:/usr/bin:/bin:/usr/sbin:/sbin"

              EDIT: I instructed to run g++-mp-4.6, not g++ (through the Toolchain addition that i made) but qmake "effective call" goes like this: "qmake /Users/objectref/Projects/tests/C++/eSTL1/eSTL1.pro -r -spec macx-g++ CONFIG+=declarative_debug"

              1 Reply Last reply
              0
              • D Offline
                D Offline
                Duck
                wrote on last edited by
                #7

                You should at least use QMAKE_CXXFLAGS += ...

                Just "=" overwrites anything that was already there.

                1 Reply Last reply
                0
                • O Offline
                  O Offline
                  objectref
                  wrote on last edited by
                  #8

                  Hi,

                  i am indeed use it in .pro file as you say. (It was just a typo in my above post.)

                  So, my .pro file is:

                  QMAKE_CXXFLAGS += -std=c++0x
                  TEMPLATE = app
                  CONFIG += console
                  CONFIG -= qt
                  SOURCES += main.cpp

                  Any ideas of what is going on ?

                  EDIT: i use the "+" before the "=" but when i post to the forum i only get the "=" (an the rest) underlined!!

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    objectref
                    wrote on last edited by
                    #9

                    In /opt/local/bin there is g++ (gcc 4.2) as well as g++-mp-4.6 (gcc 4.6). It seems to insist calling g++ and not g++-mp-4.6 even though in toolchain i specifically selected the second one...

                    1 Reply Last reply
                    0
                    • O Offline
                      O Offline
                      objectref
                      wrote on last edited by
                      #10

                      Hi again!

                      Does anyone find a solution to this ?

                      Thanks for any help!

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        tobias.hunger
                        wrote on last edited by
                        #11

                        Yeap, qmake will call whatever the mkspec tells it to, there is little we can do to override that from Qt Creator:-(

                        You can either install the different gccs into separate directories to work around the issue or add a new mkspec that uses the correct compiler to your Qt and ask creator to use that one. You can then override the mkspec used in your project or (with a creator from master) override the mkspec in the tool chain.

                        1 Reply Last reply
                        0
                        • O Offline
                          O Offline
                          objectref
                          wrote on last edited by
                          #12

                          Ok Tobias, thanks for the help!

                          I will follow your instructions. Still, i was expecting something less complicated...

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            stephenju
                            wrote on last edited by
                            #13

                            You can try MacPorts select command to make gcc46 the default gcc from opt/:
                            @
                            $ sudo port select gcc mp-gcc46@

                            Creator will than be able to pass -std=c++0x to the correct compiler. Note that -arch option is not available in non-Apple gcc. With Creator 2.5 RC, it insists on adding CONFIG+=x86_64 to qmake step, which in turn causes gcc to error on -arch option.

                            1 Reply Last reply
                            0
                            • P Offline
                              P Offline
                              Petrodynamics
                              wrote on last edited by
                              #14

                              I'm stuck just getting started with the example using creator on the Mac.

                              #include <QApplication>
                              #include <QDialog>

                              #include "ui_gotocelldialog.h"

                              int main(int argc, char *argv[])
                              {
                              QApplication app(argc, argv);

                              Ui::GoToCellDialog ui;
                              QDialog dialog = new QDialog;
                              ui.setupUi( dialog ); //compile error here: no matching function for call to 'UI::GoToCellDialog::setupUi(QDialog
                              &)'
                              // ui.setupUi( (QMainWindow*)dialog ); //Mac compiler needs the typecast to QMainWindow
                              // to compile but encountered EXC_BAD_ACCESS on runtime
                              dialog->show();

                              return app.exec();
                              }

                              from ui_gotocelldialog.h

                              void setupUi(QMainWindow *GoToCellDialog)
                              

                              Any thoughts are much appreciated!

                              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