1

Although I tried what was suggested in How to enable C++11 in Qt Creator?

this did not work with my Qt Creator using Qt 4.8 in mac os x snow leopard 10.6.8. When compiling with GCC 4.9, adding:

QMAKE_CXXFLAGS += -std=c++11

I get

cc1plus: error: unrecognized command line option "-std=c++11"

Is this meant to be compatible by Qt 4.8 like the link above said? or not?

Community
  • 1
  • 1
Wall-E
  • 623
  • 5
  • 17
  • From the error you get, I think that you don't compile with g++ 4.9. QMAKE_CXXFLAGS are just passed to underlying C++ compiler. See the compiler output window and check which compiler is invoked. – Jakiša Tomić Jul 13 '15 at 22:18
  • Probably old compilers from Snow Leopard don't support C++11. You'd need to compile Qt yourself using gcc 4.9 for this to work, and you'd need to use that self-compiled build to then build your project. Did you? – Kuba hasn't forgotten Monica Jul 13 '15 at 23:29
  • my compiler used is the one /usr/bin/g++ according to the Qt Creator project menu. g++ -v confirms i'm using g++ 4.9. How else can I make sure i'm actually using this? – Wall-E Jul 13 '15 at 23:32
  • I used the Qt 4.8 installer, I didn't compile Qt myself. – Wall-E Jul 13 '15 at 23:33
  • Are you suggesting I download the source from there: http://download.qt.io/archive/qt/4.8/4.8.6/ and build from it? If yes, is qt-everywhere-opensource-src-4.8.6* the correct archive to download? Do i just need to have gcc 4.9 as my /usr/bin/gcc or do i need something else? And there a macports or something that does that for SL 10.6.8 with a given compiler (here, 4.9)? – Wall-E Jul 13 '15 at 23:40
  • 2
    Compiling Qt can't help you if the compiler doesn't accept -std=c++11. – Hamish Moffatt Jul 14 '15 at 00:15
  • Are you sure that you are using g++ from the command line? `which g++`? And that `/usr/bin/g++ -v` says 4.9? – Hamish Moffatt Jul 14 '15 at 00:17
  • $ g++ -v (...) Thread model: posix gcc version 4.9.3 (MacPorts gcc49 4.9.3_0) And the compiler path in Qt Creator is this one, i.e, /usr/bin/g++ – Wall-E Jul 14 '15 at 08:45
  • My mistake, you guys are right. which g++ gives me g++ from macports in /opt/local/bin/g++ , although I selected with a "select" command that my g++ should be that one, it is not. /usr/bin/g++ -v is g++ 4.2. How can i fix this in the cleanest way ? – Wall-E Jul 14 '15 at 09:42
  • `/usr/bin/g++` will always be some Apple version, this should never be overridden by anything else. If it is, your system is broken. So what you see is perfectly normal. In Qt Creator, you can add desired compilers, and create a kit that uses the compiler you specified. But you definitely should also compile the Qt using that compiler, as otherwise you will run into binary incompatibilities. Make sure that you're using the proper makespec for the compiler you're using. It's possible that no such makespec exists (I wouldn't be surprised). – Kuba hasn't forgotten Monica Jul 14 '15 at 18:44

1 Answers1

0

You can try to force the compiler you want to use in the .pro file:

QMAKE_CC = full path of gcc (for ex. /opt/local/bin/gcc49)
QMAKE_CXX = full path of g++
QMAKE_LINK = full path of g++
QMAKE_LINK_SHLIB_CMD = full path of g++
yostane
  • 383
  • 1
  • 4
  • 19
  • I tried first to change this with the Qt creator project menu, there we can setup manually the path of g++. Then I tried with your QMAKE options. In both cases, I get this: g++: error: unrecognized command line option '-Xarch_x86_64' From what I read elsewhere when googling around, this happens with non-apple GCC. – Wall-E Jul 14 '15 at 16:56
  • Just in case, have you tried to use another compiler like GCC 4.7 or GCC 5.1? – yostane Jul 17 '15 at 18:48
  • No I haven't. I can give it a try after installing them too. – Wall-E Jul 17 '15 at 23:05