Qt issues on mac osx 9

  • I get the following when trying to build a project on mac in qtcreator:

    In file included from src/main.cpp:4:
    In file included from /Users/d/Qt/5.3/clang_64/lib/QtGui.framework/Headers/QGuiApplication:1:
    In file included from /Users/d/Qt/5.3/clang_64/lib/QtGui.framework/Versions/5/Headers/qguiapplication.h:47:
    /Users/d/Qt/5.3/clang_64/lib/QtGui.framework/Headers/qinputmethod.h:90:5: error: unknown type name 'QLocale'
    QLocale locale() const;

    This is my main.cpp:

    basic OpenGL demo modified from http://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html
    #include <QtGui/QGuiApplication>
    #include <iostream>
    #include "NGLScene.h"

    int main(int argc, char **argv)
    QGuiApplication app(argc, argv);
    // create an OpenGL format specifier
    QSurfaceFormat format;
    // set the number of samples for multisampling
    // will need to enable glEnable(GL_MULTISAMPLE); once we have a context
    #if defined( DARWIN)
    // at present mac osx Mountain Lion only supports GL3.2
    // the new mavericks will have GL 4.x so can change
    // with luck we have the latest GL version so set to this
    // now we are going to set to CoreProfile OpenGL so we can't use and old Immediate mode GL
    // now set the depth buffer to 24 bits
    // now we are going to create our scene window
    NGLScene window;
    // and set the OpenGL format
    // we can now query the version to see if it worked
    std::cout<<"Profile is "<<format.majorVersion()<<" "<<format.minorVersion()<<"\n";
    // set the window size
    window.resize(1024, 720);
    // and finally show

    return app.exec();

    Weird thing is the line 4 from main.cpp is just "#include < QtGui/QGuiApplication >" so everything else is just coming from Qt??

    Qt Creator was installed using the qtcreator mac package. And Qt was installed from source using the instructions here: http://qt-project.org/doc/qt-5/macosx-building.html

    Thanks for the syntax example... her is the .pro file:


    This specifies the exe name


    where to put the .o files


    core Qt Libs to use add more here if needed.

    QT+=gui opengl core

    as I want to support 4.8 and 5 this will set a flag for some of the mac stuff

    mainly in the types.h file for the setMacVisual which is native in Qt5

    isEqual(QT_MAJOR_VERSION, 5) {

    where to put moc auto generated files


    on a mac we don't create a .app bundle file ( for ease of multiplatform use)


    Auto include all .cpp files in the project src directory (can specifiy individually if required)

    SOURCES+= $$PWD/src/*.cpp

    same for the .h files

    HEADERS+= $$PWD/include/*.h

    and add the include dir into the search path for Qt and make

    INCLUDEPATH +=./include
    INCLUDEPATH += /opt/local/include

    where our exe is going to live (root of project)


    add the glsl shader files

    OTHER_FILES+= shaders/*.glsl

    were are going to default to a console app

    CONFIG += console

    note each command you add needs a ; as it will be run as a single line

    first check if we are shadow building or not easiest way is to check out against current

    !equals(PWD, $${OUT_PWD}){
    copydata.commands = echo "creating destination dirs" ;

    now make a dir

    copydata.commands += mkdir -p $$OUT_PWD/shaders ;
    copydata.commands += echo "copying files" ;

    then copy the files

    copydata.commands += $(COPY_DIR) $$PWD/shaders/* $$OUT_PWD/shaders/ ;

    now make sure the first target is built before copy

    first.depends = $(first) copydata

    now add it as an extra target

    QMAKE_EXTRA_TARGETS += first copydata

    use this to suppress some warning from boost

    QMAKE_CXXFLAGS_WARN_ON += "-Wno-unused-parameter"

    basic compiler flags (not all appropriate for all platforms)

    QMAKE_CXXFLAGS+= -msse -msse2 -msse3
    macx:QMAKE_CXXFLAGS+= -arch x86_64
    linux-g++:QMAKE_CXXFLAGS += -march=native
    linux-g++-64:QMAKE_CXXFLAGS += -march=native

    define the _DEBUG flag for the graphics lib


    unix:LIBS += -L/usr/local/lib

    add the ngl lib

    unix:LIBS += -L/$(HOME)/NGL/lib -l NGL

    now if we are under unix and not on a Mac (i.e. linux)

    :QMAKE_CXXFLAGS += -march=native

    if we are on a mac define DARWIN

    macx:DEFINES += DARWIN
    macx:LIBS += -L/opt/local/LIBS
    macx:LIBS += -lboost_system-mt -lboost_filesystem-mt

    this is where to look for includes

    INCLUDEPATH += $$(HOME)/NGL/include/

    win32: {
    INCLUDEPATH+=-I c:/boost
    DEFINES += WIN32
    LIBS += -LC:/NGL/lib/ -lNGL


    [edit: added missing coding tags @ SGaist]

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you using a pro file to manage your project ? If so can you post it ?

  • I've edited the original to include the .pro.... actually the project and the associated library can be downloaded here:



  • Lifetime Qt Champion

    Are you saying that it happens when your build that library ? Or just when trying to use ?

  • I'm using the library - it's been built already. I know that it works I have class mates who are using it ok - this is an issue with qt on my machine.

  • here is the compilation output:

    In file included from include/NGLScene.h:7:
    In file included from /Users/d/NGL/include/ngl/Text.h:45:
    In file included from /Users/d/Qt/5.3/clang_64/lib/QtGui.framework/Versions/5/Headers/QFont:1:
    /Users/d/Qt/5.3/clang_64/lib/QtGui.framework/Versions/5/Headers/qfont.h:320:59: error: expected function body after function declarator
    Q_GUI_EXPORT uint qHash(const QFont &font, uint seed = 0) Q_DECL_NOTHROW;
    1 warning and 15 errors generated.
    make: *** [obj/main.o] Error 1
    19:47:36: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project SimpleNGL (kit: Desktop Qt 5.3 clang 64bit)
    When executing step "Make"
    19:47:36: Elapsed time: 00:02.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.