Qmake 4.8.2 unresolved external symbol QSystemLocale

So, after updating my Qt version to 4.8.2 I encounter another compilation problems (as usual 😉 ).

As first, this is my linker output:

qlocale.obj : error LNK2001: unresolved external symbol "public: virtual class QVariant __thiscall QSystemLocale::query(enum QSystemLocale::QueryType,class QVariant)const " (?query@QSystemLocale@@UBE?AVQVariant@@W4QueryType@1@V2@@Z)
1>qlocale.obj : error LNK2001: unresolved external symbol "public: virtual class QLocale __thiscall QSystemLocale::fallbackLocale(void)const " (?fallbackLocale@QSystemLocale@@UBE?AVQLocale@@XZ)
1>qlocale.obj : error LNK2019: unresolved external symbol "class QString & __cdecl decimalForm(class QChar,class QChar,class QChar,class QString &,int,unsigned int,enum PrecisionMode,bool,bool)" (?decimalForm@@YAAAVQString@@VQChar@@00AAV1@HIW4PrecisionMode@@_N3@Z) referenced in function "public: static class QString __cdecl QLocalePrivate::doubleToString(class QChar,class QChar,class QChar,class QChar,class QChar,class QChar,double,int,enum QLocalePrivate::DoubleForm,int,unsigned int)" (?doubleToString@QLocalePrivate@@SA?AVQString@@VQChar@@00000NHW4DoubleForm@1@HI@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "class QString & __cdecl exponentForm(class QChar,class QChar,class QChar,class QChar,class QChar,class QChar,class QString &,int,unsigned int,enum PrecisionMode,bool)" (?exponentForm@@YAAAVQString@@VQChar@@00000AAV1@HIW4PrecisionMode@@_N@Z) referenced in function "public: static class QString __cdecl QLocalePrivate::doubleToString(class QChar,class QChar,class QChar,class QChar,class QChar,class QChar,double,int,enum QLocalePrivate::DoubleForm,int,unsigned int)" (?doubleToString@QLocalePrivate@@SA?AVQString@@VQChar@@00000NHW4DoubleForm@1@HI@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "char * __cdecl qdtoa(double,int,int,int *,int *,char * *,char * *)" (?qdtoa@@YAPADNHHPAH0PAPAD1@Z) referenced in function "public: static class QString __cdecl QLocalePrivate::doubleToString(class QChar,class QChar,class QChar,class QChar,class QChar,class QChar,double,int,enum QLocalePrivate::DoubleForm,int,unsigned int)" (?doubleToString@QLocalePrivate@@SA?AVQString@@VQChar@@00000NHW4DoubleForm@1@HI@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "class QString __cdecl qulltoa(unsigned __int64,int,class QChar)" (?qulltoa@@YA?AVQString@@_KHVQChar@@@Z) referenced in function "public: static class QString __cdecl QLocalePrivate::longLongToString(class QChar,class QChar,class QChar,class QChar,__int64,int,int,int,unsigned int)" (?longLongToString@QLocalePrivate@@SA?AVQString@@VQChar@@000_JHHHI@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "class QString __cdecl qlltoa(__int64,int,class QChar)" (?qlltoa@@YA?AVQString@@_JHVQChar@@@Z) referenced in function "public: static class QString __cdecl QLocalePrivate::longLongToString(class QChar,class QChar,class QChar,class QChar,__int64,int,int,int,unsigned int)" (?longLongToString@QLocalePrivate@@SA?AVQString@@VQChar@@000_JHHHI@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "bool __cdecl removeGroupSeparators(class QVarLengthArray<char,256> *)" (?removeGroupSeparators@@YA_NPAV?$QVarLengthArray@D$0BAA@@@@Z) referenced in function "public: bool __thiscall QLocalePrivate::numberToCLocale(class QString const &,enum QLocalePrivate::GroupSeparatorMode,class QVarLengthArray<char,256> *)const " (?numberToCLocale@QLocalePrivate@@QBE_NABVQString@@W4GroupSeparatorMode@1@PAV?$QVarLengthArray@D$0BAA@@@@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "double __cdecl qstrtod(char const *,char const * *,bool *)" (?qstrtod@@YANPBDPAPBDPA_N@Z) referenced in function "public: static double __cdecl QLocalePrivate::bytearrayToDouble(char const *,bool *,bool *)" (?bytearrayToDouble@QLocalePrivate@@SANPBDPA_N1@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "__int64 __cdecl qstrtoll(char const *,char const * *,int,bool *)" (?qstrtoll@@YA_JPBDPAPBDHPA_N@Z) referenced in function "public: static __int64 __cdecl QLocalePrivate::bytearrayToLongLong(char const *,int,bool *,bool *)" (?bytearrayToLongLong@QLocalePrivate@@SA_JPBDHPA_N1@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "unsigned __int64 __cdecl qstrtoull(char const *,char const * *,int,bool *)" (?qstrtoull@@YA_KPBDPAPBDHPA_N@Z) referenced in function "public: static unsigned __int64 __cdecl QLocalePrivate::bytearrayToUnsLongLong(char const *,int,bool *)" (?bytearrayToUnsLongLong@QLocalePrivate@@SA_KPBDHPA_N@Z)
1>..\bin\\qmake.exe : fatal error LNK1120: 11 unresolved externals

The reason for this is missing two definitions in qmake.pri.

First is system-dependent qlocale_win.cpp / qlocale_unix.cpp. For fixing it you have to update these to files to unix{} and win32{}

 unix {
        SOURCES += qfilesystemengine_unix.cpp qfilesystemiterator_unix.cpp qfsfileengine_unix.cpp qlocale_unix.cpp #<<---- HERE
        mac {
          SOURCES += qfilesystemengine_mac.cpp
          SOURCES += qcore_mac.cpp qsettings_mac.cpp
          QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported)
          LIBS += -framework ApplicationServices
        }
    } else:win32 {
        SOURCES += qfilesystemengine_win.cpp qfsfileengine_win.cpp qfilesystemiterator_win.cpp qsettings_win.cpp \
            qsystemlibrary.cpp qlocale_win.cpp #<<--------- AND HERE
        win32-msvc*:LIBS += ole32.lib advapi32.lib
        win32-g++*:LIBS += -lole32 -luuid -ladvapi32 -lkernel32
    }

If you update .pri like this, you will gain another cute unresolved external:

qlocale.obj : error LNK2019: unresolved external symbol "class QString & __cdecl decimalForm(class QChar,class QChar,class QChar,class QString &,int,unsigned int,enum PrecisionMode,bool,bool)" (?decimalForm@@YAAAVQString@@VQChar@@00AAV1@HIW4PrecisionMode@@_N3@Z) referenced in function "public: static class QString __cdecl QLocalePrivate::doubleToString(class QChar,class QChar,class QChar,class QChar,class QChar,class QChar,double,int,enum QLocalePrivate::DoubleForm,int,unsigned int)" (?doubleToString@QLocalePrivate@@SA?AVQString@@VQChar@@00000NHW4DoubleForm@1@HI@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "class QString & __cdecl exponentForm(class QChar,class QChar,class QChar,class QChar,class QChar,class QChar,class QString &,int,unsigned int,enum PrecisionMode,bool)" (?exponentForm@@YAAAVQString@@VQChar@@00000AAV1@HIW4PrecisionMode@@_N@Z) referenced in function "public: static class QString __cdecl QLocalePrivate::doubleToString(class QChar,class QChar,class QChar,class QChar,class QChar,class QChar,double,int,enum QLocalePrivate::DoubleForm,int,unsigned int)" (?doubleToString@QLocalePrivate@@SA?AVQString@@VQChar@@00000NHW4DoubleForm@1@HI@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "char * __cdecl qdtoa(double,int,int,int *,int *,char * *,char * *)" (?qdtoa@@YAPADNHHPAH0PAPAD1@Z) referenced in function "public: static class QString __cdecl QLocalePrivate::doubleToString(class QChar,class QChar,class QChar,class QChar,class QChar,class QChar,double,int,enum QLocalePrivate::DoubleForm,int,unsigned int)" (?doubleToString@QLocalePrivate@@SA?AVQString@@VQChar@@00000NHW4DoubleForm@1@HI@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "class QString __cdecl qulltoa(unsigned __int64,int,class QChar)" (?qulltoa@@YA?AVQString@@_KHVQChar@@@Z) referenced in function "public: static class QString __cdecl QLocalePrivate::longLongToString(class QChar,class QChar,class QChar,class QChar,__int64,int,int,int,unsigned int)" (?longLongToString@QLocalePrivate@@SA?AVQString@@VQChar@@000_JHHHI@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "class QString __cdecl qlltoa(__int64,int,class QChar)" (?qlltoa@@YA?AVQString@@_JHVQChar@@@Z) referenced in function "public: static class QString __cdecl QLocalePrivate::longLongToString(class QChar,class QChar,class QChar,class QChar,__int64,int,int,int,unsigned int)" (?longLongToString@QLocalePrivate@@SA?AVQString@@VQChar@@000_JHHHI@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "bool __cdecl removeGroupSeparators(class QVarLengthArray<char,256> *)" (?removeGroupSeparators@@YA_NPAV?$QVarLengthArray@D$0BAA@@@@Z) referenced in function "public: bool __thiscall QLocalePrivate::numberToCLocale(class QString const &,enum QLocalePrivate::GroupSeparatorMode,class QVarLengthArray<char,256> *)const " (?numberToCLocale@QLocalePrivate@@QBE_NABVQString@@W4GroupSeparatorMode@1@PAV?$QVarLengthArray@D$0BAA@@@@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "double __cdecl qstrtod(char const *,char const * *,bool *)" (?qstrtod@@YANPBDPAPBDPA_N@Z) referenced in function "public: static double __cdecl QLocalePrivate::bytearrayToDouble(char const *,bool *,bool *)" (?bytearrayToDouble@QLocalePrivate@@SANPBDPA_N1@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "__int64 __cdecl qstrtoll(char const *,char const * *,int,bool *)" (?qstrtoll@@YA_JPBDPAPBDHPA_N@Z) referenced in function "public: static __int64 __cdecl QLocalePrivate::bytearrayToLongLong(char const *,int,bool *,bool *)" (?bytearrayToLongLong@QLocalePrivate@@SA_JPBDHPA_N1@Z)
1>qlocale_win.obj : error LNK2001: unresolved external symbol "__int64 __cdecl qstrtoll(char const *,char const * *,int,bool *)" (?qstrtoll@@YA_JPBDPAPBDHPA_N@Z)
1>qlocale.obj : error LNK2019: unresolved external symbol "unsigned __int64 __cdecl qstrtoull(char const *,char const * *,int,bool *)" (?qstrtoull@@YA_KPBDPAPBDHPA_N@Z) referenced in function "public: static unsigned __int64 __cdecl QLocalePrivate::bytearrayToUnsLongLong(char const *,int,bool *)" (?bytearrayToUnsLongLong@QLocalePrivate@@SA_KPBDHPA_N@Z)
1>qlocale_win.obj : error LNK2001: unresolved external symbol "unsigned __int64 __cdecl qstrtoull(char const *,char const * *,int,bool *)" (?qstrtoull@@YA_KPBDPAPBDHPA_N@Z)
1>..\bin\\qmake.exe : fatal error LNK1120: 9 unresolved externals

Also this linker error is caused by missing file in SOURCE definition. In this case add qlocale_tools.cpp to SOURCE in bootstrap { #Qt code


bootstrap { #Qt code
   DEFINES+=QT_NODLL QT_NO_THREAD
   SOURCES+= \
        qbitarray.cpp \
        qbuffer.cpp \
        qbytearray.cpp \
        qbytearraymatcher.cpp \
        qcryptographichash.cpp \
        qdatetime.cpp \
        qdir.cpp \
        qdiriterator.cpp \
        qfile.cpp \
        qabstractfileengine.cpp \
        qfileinfo.cpp \
        qfilesystementry.cpp \
        qfilesystemengine.cpp \
        qfsfileengine.cpp \
        qfsfileengine_iterator.cpp \
        qglobal.cpp \
        qnumeric.cpp \
        qhash.cpp \
        qiodevice.cpp \
        qlist.cpp \
        qlinkedlist.cpp \
        qlocale.cpp \
        qlocale_tools.cpp \  #<< ----- HERE

Now re-call qmake and recompile it. Everything should works ok. The question is, why no-one in Qt didn’t find this error.

2 comments

  1. You saved my day!

    Got some similar problems with the git master from today! (13.01.2014 !)

    – It seems, the Qt team did not merge your bugfix.

    Did you try to upload it into the Git repository? Or got some response?

    1. I don’t have a good experience with posting bugs back to Qt repository. Please feel free to try to upload it to Qt repositories if you would like.

Leave a Reply

Your email address will not be published. Required fields are marked *