iOS compiling error: qchar.h:45:1: error: unknown type name 'QT_BEGIN_NAMESPACE'



  • When compile with iOS appears these errors:

    In file included from ../../Qt/5.7/ios/include/QtCore/qstring.h:48:
    ../../Qt/5.7/ios/include/QtCore/qchar.h:45:1: error: unknown type name 'QT_BEGIN_NAMESPACE'
    QT_BEGIN_NAMESPACE
    ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:48:1: error: expected unqualified-id
    class QString;
    ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:55:29: error: unknown type name 'ushort'; did you mean 'short'?
        Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ushort(uchar(ch)); }
                                ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:55:83: error: use of undeclared identifier 'uchar'; did you mean 'char'?
        Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ushort(uchar(ch)); }
                                                                                      ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:55:36: error: no return statement in constexpr function
        Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ushort(uchar(ch)); }
                                       ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:63:1: error: expected expression
    public:
    ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:333:24: error: token is not a valid binary operator in a preprocessor subexpression
    #if QT_DEPRECATED_SINCE(5, 3)
        ~~~~~~~~~~~~~~~~~~~^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:390:24: error: token is not a valid binary operator in a preprocessor subexpression
    #if QT_DEPRECATED_SINCE(5, 3)
        ~~~~~~~~~~~~~~~~~~~^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:422:24: error: token is not a valid binary operator in a preprocessor subexpression
    #if QT_DEPRECATED_SINCE(5, 0)
        ~~~~~~~~~~~~~~~~~~~^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:429:24: error: token is not a valid binary operator in a preprocessor subexpression
    #if QT_DEPRECATED_SINCE(5, 0)
        ~~~~~~~~~~~~~~~~~~~^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:500:24: error: token is not a valid binary operator in a preprocessor subexpression
    #if QT_DEPRECATED_SINCE(5, 3)
        ~~~~~~~~~~~~~~~~~~~^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:62:21: error: variable has incomplete type 'class Q_CORE_EXPORT'
    class Q_CORE_EXPORT QChar {
                        ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:62:7: note: forward declaration of 'Q_CORE_EXPORT'
    class Q_CORE_EXPORT QChar {
          ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:571:1: error: C++ requires a type specifier for all declarations
    Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE);
    ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:571:27: error: use of undeclared identifier 'Q_MOVABLE_TYPE'
    Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE);
                              ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:573:41: error: unknown type name 'QChar'
    Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs == c2.ucs; }
                                            ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:573:51: error: unknown type name 'QChar'
    Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs == c2.ucs; }
                                                      ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:574:41: error: unknown type name 'QChar'
    Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs <  c2.ucs; }
                                            ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:574:51: error: unknown type name 'QChar'
    Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs <  c2.ucs; }
                                                      ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:576:41: error: unknown type name 'QChar'
    Q_DECL_CONSTEXPR inline bool operator!=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator==(c1, c2); }
                                            ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    
    
    ** BUILD FAILED **
    

  • Lifetime Qt Champion

    Hi,

    Which version of Xcode are you using ? What parameter did you pass to configure ?



  • With XCode 7.0.1 gives this error. After update to XCode 7.3.1, continues with the same. The Mac is OSX El Capitan 10.11.6.

    The same project is compiled (on windows environment) for Windows and Android, and compiles and runs without errors.

    I don't pass any parameter to XCode, is necessary any parameter? When the project is compiled, QT generates the XCode project on the build directory. If opens and compiles on XCode with the XCode project generated, the same error appears .


  • Lifetime Qt Champion

    Did you build Qt yourself or are you using the official package ?



  • The official package.

    The installation is on the default directory (Qt on user directory) and I've selected only these options:

    • Qt \ Qt 5.7 \ iOS
    • Qt \ Tools

    After, I've updated the installation and included Qt \ Qt 5.7 \ Sources, but continues with the same error.


  • Lifetime Qt Champion

    Can you share your .pro file ?



  • .pro:

    TEMPLATE = app
    
    VERSION = 0.9  #main.cpp
    
    QT += qml quick positioning network multimedia location
    
    DEFINES += _7ZIP_ST SSL_ENABLED
    DEFINES += APP_VERSION=\\\"$$VERSION\\\"  # main.cpp
    #DEFINES += SSL_LOCAL    # networkManager.cpp settings.cpp
    #DEFINES += SIMULATE_GPS  # positionManager.cpp
    
    TRANSLATIONS = es.ts \
                   pt_br.ts
    
    android {
        include(android.pri)
    }
    
    windows {
        include(windows.pri)
    }
    
    ios {
        include(ios.pri)
    }
    
    SOURCES += main.cpp \
        ... CPP files
    
    RESOURCES += \
        resources.qrc
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Default rules for deployment.
    include(deployment.pri)
    
    HEADERS += \
        ... H files
    
    lupdate_only {
    SOURCES += \
        ... QML files
    }
    
    CONFIG += c++14
    #CONFIG+=qml_debug
    
    INCLUDEPATH += util/lzma
    
    

    ios.pri:

    SOURCES += \
        util/image/imagePickerIos.cpp
    
    HEADERS += \
        util/image/imagePickerIos.h
    

    deployment.pri (never edited by me):

    android-no-sdk {
        target.path = /data/user/qt
        export(target.path)
        INSTALLS += target
    } else:android {
        x86 {
            target.path = /libs/x86
        } else: armeabi-v7a {
            target.path = /libs/armeabi-v7a
        } else {
            target.path = /libs/armeabi
        }
        export(target.path)
        INSTALLS += target
    } else:unix {
        isEmpty(target.path) {
            qnx {
                target.path = /tmp/$${TARGET}/bin
            } else {
                target.path = /opt/$${TARGET}/bin
            }
            export(target.path)
        }
        INSTALLS += target
    }
    
    export(INSTALLS)
    


  • This is the complete output:

    06:13:48: Running steps for project MyApp...
    06:13:48: Starting: "/Users/test/Qt/5.7/ios/bin/qmake" /Users/test/Documents/src/MyApp.pro -r -spec macx-ios-clang CONFIG+=iphoneos CONFIG+=device CONFIG+=qml_debug
    06:13:51: The process "/Users/test/Qt/5.7/ios/bin/qmake" exited normally.
    06:13:51: Starting: "/usr/bin/make" 
    xcodebuild build -scheme MyApp  -sdk iphoneos  -configuration Debug  -destination "generic/platform=iOS" -destination-timeout 1
    Build settings from command line:
        SDKROOT = iphoneos9.3
    
    
    2016-08-23 06:13:53.834 xcodebuild[432:6704] warning:  The file reference for "/Users/test/Documents/src/resources.qrc" is a member of multiple groups ("Supporting Files" and "Resources"); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
    === BUILD AGGREGATE TARGET Qt Preprocess OF PROJECT MyApp WITH CONFIGURATION Debug ===
    
    
    Check dependencies
    
    
    PhaseScriptExecution Qt\ Qmake MyApp.build/Debug-iphoneos/Qt\ Preprocess.build/Script-5E618435888B9D49F8540165.sh
        cd /Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug
        /bin/sh -c \"/Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug/MyApp.build/Debug-iphoneos/Qt\ Preprocess.build/Script-5E618435888B9D49F8540165.sh\"
    make[1]: `MyApp.xcodeproj/project.pbxproj' is up to date.
    
    
    PhaseScriptExecution Qt\ Preprocessors MyApp.build/Debug-iphoneos/Qt\ Preprocess.build/Script-7EF0942E79C014DCEC8976BC.sh
        cd /Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug
        /bin/sh -c \"/Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug/MyApp.build/Debug-iphoneos/Qt\ Preprocess.build/Script-7EF0942E79C014DCEC8976BC.sh\"
    make[1]: Nothing to be done for `preprocess'.
    
    
    === BUILD TARGET MyApp OF PROJECT MyApp WITH CONFIGURATION Debug ===
    
    
    Check dependencies
    The provisioning profile "iOS Team Provisioning Profile: com.shaphymo.MyApp" is expiring soon
    
    
    CompileC MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/main.o /Users/test/Documents/src/main.cpp normal armv7 c++ com.apple.compilers.llvm.clang.1_0.compiler
        cd /Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug
        export LANG=en_US.US-ASCII
        export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -miphoneos-version-min=6.0 -g -fvisibility=hidden -fvisibility-inlines-hidden -Wno-sign-conversion -I/Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug/MyApp.build/Debug-iphoneos/MyApp.build/MyApp.hmap -I/Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug/Debug-iphoneos/include -I../src -I. -I/Users/test/Qt/5.7/ios/mkspecs/macx-ios-clang/ios -I../src/util/lzma -I../../Qt/5.7/ios/include -I../../Qt/5.7/ios/include/QtLocation -I../../Qt/5.7/ios/include/QtQuick -I../../Qt/5.7/ios/include/QtMultimedia -I../../Qt/5.7/ios/include/QtGui -I../../Qt/5.7/ios/include/QtQml -I../../Qt/5.7/ios/include/QtNetwork -I../../Qt/5.7/ios/include/QtPositioning -I../../Qt/5.7/ios/include/QtCore -I../../Qt/5.7/ios/mkspecs/macx-ios-clang -I/Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug/MyApp.build/Debug-iphoneos/MyApp.build/DerivedSources/armv7 -I/Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug/MyApp.build/Debug-iphoneos/MyApp.build/DerivedSources -F/Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug/Debug-iphoneos -pipe -stdlib=libc++ -fvisibility=hidden -fpascal-strings -fmessage-length=0 -Wno-trigraphs -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -Wno-sign-conversion -fexceptions -fasm-blocks -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-implicit-atomic-properties -Wformat -Wno-missing-braces -Wno-unused-function -Wno-unused-label -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-sign-compare -Wpointer-sign -Wno-newline-eof -Wdeprecated-declarations -Winvalid-offsetof -Wno-conversion -fvisibility-inlines-hidden -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -g -std=gnu++1y -fobjc-nonfragile-abi -fobjc-legacy-dispatch -Wno-deprecated-implementations -Wprotocol -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wall -W -fPIC -DDARWIN_NO_CARBON -DQT_NO_PRINTER -DQT_NO_PRINTDIALOG -D_7ZIP_ST -DSSL_ENABLED -DAPP_VERSION=\"0.8.6\" -DQT_QML_DEBUG -DQT_LOCATION_LIB -DQT_QUICK_LIB -DQT_MULTIMEDIA_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_POSITIONING_LIB -DQT_CORE_LIB -MMD -MT dependencies -MF /Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/main.d --serialize-diagnostics /Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/main.dia -c /Users/test/Documents/src/main.cpp -o /Users/test/Documents/build-MyApp-iphoneos_clang_Qt_5_7_0_for_iOS-Debug/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/main.o
    In file included from /Users/test/Documents/src/main.cpp:1:
    In file included from ../src/MyAppApplication.h:3:
    In file included from ../../Qt/5.7/ios/include/QtCore/QSettings:1:
    In file included from ../../Qt/5.7/ios/include/QtCore/qsettings.h:43:
    In file included from ../../Qt/5.7/ios/include/QtCore/qobject.h:46:
    In file included from ../../Qt/5.7/ios/include/QtCore/qobjectdefs.h:48:
    In file included from ../../Qt/5.7/ios/include/QtCore/qnamespace.h:43:
    In file included from ../../Qt/5.7/ios/include/QtCore/qglobal.h:94:
    In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:628:
    In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:606:
    In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iterator:346:
    In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:90:
    In file included from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/usr/include/wchar.h:91:
    In file included from /Users/test/Documents/src/types/time.h:5:
    In file included from ../../Qt/5.7/ios/include/QtCore/QDateTime:1:
    In file included from ../../Qt/5.7/ios/include/QtCore/qdatetime.h:43:
    In file included from ../../Qt/5.7/ios/include/QtCore/qstring.h:48:
    ../../Qt/5.7/ios/include/QtCore/qchar.h:45:1: error: unknown type name 'QT_BEGIN_NAMESPACE'
    QT_BEGIN_NAMESPACE
    ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:48:1: error: expected unqualified-id
    class QString;
    ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:55:29: error: unknown type name 'ushort'; did you mean 'short'?
        Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ushort(uchar(ch)); }
                                ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:55:83: error: use of undeclared identifier 'uchar'; did you mean 'char'?
        Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ushort(uchar(ch)); }
                                                                                      ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:55:36: error: no return statement in constexpr function
        Q_DECL_CONSTEXPR inline ushort unicode() const Q_DECL_NOTHROW { return ushort(uchar(ch)); }
                                       ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:63:1: error: expected expression
    public:
    ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:333:24: error: token is not a valid binary operator in a preprocessor subexpression
    #if QT_DEPRECATED_SINCE(5, 3)
        ~~~~~~~~~~~~~~~~~~~^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:390:24: error: token is not a valid binary operator in a preprocessor subexpression
    #if QT_DEPRECATED_SINCE(5, 3)
        ~~~~~~~~~~~~~~~~~~~^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:422:24: error: token is not a valid binary operator in a preprocessor subexpression
    #if QT_DEPRECATED_SINCE(5, 0)
        ~~~~~~~~~~~~~~~~~~~^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:429:24: error: token is not a valid binary operator in a preprocessor subexpression
    #if QT_DEPRECATED_SINCE(5, 0)
        ~~~~~~~~~~~~~~~~~~~^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:500:24: error: token is not a valid binary operator in a preprocessor subexpression
    #if QT_DEPRECATED_SINCE(5, 3)
        ~~~~~~~~~~~~~~~~~~~^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:62:21: error: variable has incomplete type 'class Q_CORE_EXPORT'
    class Q_CORE_EXPORT QChar {
                        ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:62:7: note: forward declaration of 'Q_CORE_EXPORT'
    class Q_CORE_EXPORT QChar {
          ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:571:1: error: C++ requires a type specifier for all declarations
    Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE);
    ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:571:27: error: use of undeclared identifier 'Q_MOVABLE_TYPE'
    Q_DECLARE_TYPEINFO(QChar, Q_MOVABLE_TYPE);
                              ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:573:41: error: unknown type name 'QChar'
    Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs == c2.ucs; }
                                            ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:573:51: error: unknown type name 'QChar'
    Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs == c2.ucs; }
                                                      ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:574:41: error: unknown type name 'QChar'
    Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs <  c2.ucs; }
                                            ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:574:51: error: unknown type name 'QChar'
    Q_DECL_CONSTEXPR inline bool operator< (QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs <  c2.ucs; }
                                                      ^
    ../../Qt/5.7/ios/include/QtCore/qchar.h:576:41: error: unknown type name 'QChar'
    Q_DECL_CONSTEXPR inline bool operator!=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator==(c1, c2); }
                                            ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    20 errors generated.
    


  • I've found it!!!

    In my project exist a file with the name time.h. The iPhone SDK has another file with the same name that is included on wchar.h (SDKs/iPhoneOS9.3.sdk/usr/include/wchar.h:91) and the compiler tries to compile my file first.

    After change the file's name, all compile without problems.

    Thank you very much!


  • Lifetime Qt Champion

    Dangerous file name indeed !

    Glad you found out and thanks for sharing :)


Log in to reply
 

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