Question

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.

:(

Was it helpful?

Solution 2

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top