2

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.

Community
  • 1
  • 1
Dan Nissenbaum
  • 13,558
  • 21
  • 105
  • 181
  • How are these build problems? Sounds to me you've got this problem at runtime. There was a change in the VS2012 CRT to provide better localization support. Which won't work on XP because it doesn't have the necessary winapi functions. So do mention your test OS as well. – Hans Passant Apr 12 '13 at 17:55
  • @HansPassant This is a runtime problem for a program that is being internally executed as part of a complex Qt build script: http://stackoverflow.com/a/15893226/368896 – Dan Nissenbaum Apr 12 '13 at 18:42
  • @HansPassant (and I'm building / running on Windows 7, 64-bit, but building Qt as 32-bit under the VS2012 compiler.) – Dan Nissenbaum Apr 13 '13 at 01:56

1 Answers1

5

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).

  • This answer helped me reduce the size of Qt5 dependencies (ICU DLL's). I've done exactly the above, i.e. rebuilt ICU with the #define mentioned and voila - 20MB of dependencies less. Thanks! – sthlm58 Oct 08 '13 at 13:29