ICU support in a 32-bit build of Qt5 with the VS2012 compiler causes Qt5 build failure; Webkit is also therefore unbuildable

北慕城南 提交于 2019-12-12 16:42:22

问题


I have run into another in a long stream of obstacles attempting to build Qt5 with the VS2012 compiler.

When ICU is enabled ("-icu" on the configure command line, along with a proper 32-bit build of ICU in VS2012 and proper inclusion of all ICU paths (header, .lib, and .dll)), Line 688 of qtbase\src\corelib\codecs\qtextcodec.cpp returns a NULL codec (ICU fails to return a codec) when asked for a codec whose name is "US-ASCII".

Specifically:

QTextCodec* QTextCodec::codecForLocale()
{
    QCoreGlobalData *globalData = QCoreGlobalData::instance();
    if (!globalData)
        return 0;

    QTextCodec *codec = globalData->codecForLocale.loadAcquire();
    if (!codec) {
#ifdef QT_USE_ICU

        // THIS BLOCK IS REACHED WHEN ICU IS ENABLED

        textCodecsMutex()->lock();

        // ***
        // The following codec returned is NULL!!!
        //   (Internally, it sets the codec name to "US-ASCII",
        //    and fails to find a codec with this name)
        // ***
        codec = QIcuCodec::defaultCodecUnlocked();

        textCodecsMutex()->unlock();
#else
        // setupLocaleMapper locks as necessary
        codec = setupLocaleMapper();
#endif
    }

    return codec;
}

Later, the NULL codec variable noted above is dereferenced (in the code for the "lrelease.exe" utility), and when the "lrelease.exe" utility runs as part of the Qt5 build process and attempts to perform a translation, it crashes due to this NULL dereference and causes the Qt build to stop with an error.

Stepping into the above QIcuCodec::defaultCodecUnlocked() function reveals that the codec name is being set to US-ASCII, and that a codec with this name is not found.

It therefore seems to be impossible to include ICU support with a VS2012-compiler 32-bit build of Qt5.

Worse, because Webkit depends on ICU within Qt5, this means that Webkit cannot be built, either.

Can someone please tell me if this is reasonably likely to be a bug with Qt5 with VS2012, or is there something I am not setting up properly in my build environment?

Of use, also, would be knowing whether anybody has been able to build Qt5 with the VS2012 compiler with ICU support enabled.

I have also posted a comment in a relevant, ongoing thread in the Qt forum.


回答1:


Qt uses UTF-8 as the default. Assuming ICU 51.2, rebuild ICU with U_CHARSET_IS_UTF8 defined to 1. Either: #define it in source\common\unicode\platform.h (see comment starting about around line 523), or you could also add it to the build in all ICU projects in allinone.sln (e.g. right click, select properties, select Configuration Properties>C/C++>Preprocessor and add it to Preprocessor Definitions).



来源:https://stackoverflow.com/questions/15975608/icu-support-in-a-32-bit-build-of-qt5-with-the-vs2012-compiler-causes-qt5-build-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!