1

Just downloaded and installed Qt5 on OSX 10.9.2.

When trying to compile some C++11 code using the clang run kit, I get a failure when I try to include cstdint;

fatal error: 'cstdint' file not found

After a lot of googling, it seems that c++11 is not 'enabled' by default which triggers this error. It further seems that the way to enable c++11 has changed in Qt5. It should be as simple as adding CONFIG+=c++11 in "Projects -> Build & Run -> Build Steps -> Additional arguments" if I understand it correctly.

However this makes no difference whatsoever.

So; anyone knows how to enable c++11 using QtCreator with the clang kit?

About QtCreator gives me the following information: QtCreator 3.0.1 Based on Qt 5.2.1 (Clang 5.0 (Apple), 64 bit)

The compiler output is as follows:

14:25:23: Running steps for project shelly...
14:25:23: Starting: "/Users/m/Qt5.2.1/5.2.1/clang_64/bin/qmake" /Volumes/files/Programmering/shelly/shelly.pro -r -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=declarative_debug CONFIG+=qml_debug CONFIG+=c++11
14:25:23: The process "/Users/m/Qt5.2.1/5.2.1/clang_64/bin/qmake" exited normally.
14:25:23: Starting: "/usr/bin/make" 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -c -pipe -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.7 -Wall -W -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/Users/m/Qt5.2.1/5.2.1/clang_64/mkspecs/macx-clang -I../shelly -I/Users/m/Qt5.2.1/5.2.1/clang_64/lib/QtOpenGL.framework/Versions/5/Headers -I/Users/m/Qt5.2.1/5.2.1/clang_64/lib/QtWidgets.framework/Versions/5/Headers -I/Users/m/Qt5.2.1/5.2.1/clang_64/lib/QtGui.framework/Versions/5/Headers -I/Users/m/Qt5.2.1/5.2.1/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/m/Qt5.2.1/5.2.1/clang_64/lib -o datainterval.o ../shelly/core/datainterval.c++
In file included from ../shelly/core/datainterval.c++:5:
In file included from ../shelly/core/datainterval.h++:9:
../shelly/core/datatime.h++:9:10: fatal error: 'cstdint' file not found
#include <cstdint> // GPL w/runtime exception
         ^
1 error generated.
make: *** [datainterval.o] Error 1
14:25:24: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project shelly (kit: Desktop Qt 5.2.1 clang 64bit)
When executing step 'Make'
14:25:24: Elapsed time: 00:01.

Update:

Have made an 'minimal recreate' of my problem;

  1. Create a new project, a “Qt Widgets Application”.
  2. Leave everything at its defaults except for the path.
  3. In the created file mainwindow.c++, add the cstdint include statement:
  4. Try to build it (it fails as above)
  5. Add in “Projects” -> “Build & Run” -> “Build Steps” -> “Additional arguments”

    CONFIG+=c++11

The “Effective qmake call” line then reads

qmake /Users/m/Documents/ProgrammeringOSX/testC11/testC11.pro -r -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=declarative_debug CONFIG+=qml_debug CONFIG+=c++11

…and the error is still there.

:(

Daniel
  • 24
  • 5

2 Answers2

0

I have the same setup as you, and have used c++11 features after updating the project .pro file with the following line:

CONFIG += c++11

However, I think your solution should accomplish the same thing, so it may be an external configuration issue. I wasn't able to reproduce the error when I included the header file.

  • Thanks. Tried it as well, both with and without the LIBS & QMAKE stuff mentioned in many pages that I found via google. Have made an update with a 'minimal recreation' of my problem. – Daniel Apr 01 '14 at 21:37
  • Still wasn't able to reproduce the error with your steps. Is that the only qmake you have on your path? –  Apr 01 '14 at 22:01
  • Just saw this suggestion on a related question. Add the following to the .pro file: QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7 LIBS += -stdlib=libc++ -mmacosx-version-min=10.7 http://stackoverflow.com/a/15759514/798377 –  Apr 01 '14 at 22:04
  • Shisno; can you check your 'Compile output'? Specifically the line where the clang compiler kicks in. I expect to see '-std=c++11 -stdlib=libc++' somewhere in there, but in my line they are missing... – Daniel Apr 02 '14 at 07:00
  • Actually it seems that I can put anything in the QMAKE_CXXFLAGS, it seems to be ignored. I added "Iwonderwhatthisdoes" and the system accepted this without any error messages... something is really weird here. – Daniel Apr 02 '14 at 07:47
  • This is what the compiler output looks like: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7 ... –  Apr 02 '14 at 12:50
  • Well, as I said in the answer, I did not get the std=c++11 and stdlib entries until I set the deployment target to osx 10.9. Strange. – Daniel Apr 02 '14 at 19:29
  • Actually; I see that your line states 'clang++'... Mine says 'clang' - don't know if this has any practical consequences (may just be a symlink). – Daniel Apr 02 '14 at 19:31
0

Ok,

I seem to have “fixed” it… I got to the point that I was randomly changing parameters just to see what effect it had and all of a sudden this did it:

QMAKE_MACOSX_DEPLOYMENT_TARGET=10.9

(doesn’t matter if I set it in the .pro file or in the GUI)

If I added CONFIG+=c++11, the target was set to 10.7, without it 10.6, so this forces it to 10.9 (tried 10.8 as well, but nope; 10.9 it is).

A funny thing is that I do not need to add CONFIG+=c++11 in the “minimum recreation” version… I guess I will get to that point if I actually add any C++11 code. But baby steps, baby steps!

Another funny thing is that when I changed the target to 10.9, THEN my bogus QMAKE_CXXFLAGS parameters were added and the clang call failed (I guess it heeded my ‘pleaseFailNow’ parameter).

Thank you for your help!

Cheers / Daniel

Daniel
  • 24
  • 5