mingw-cross-env-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mingw-cross-env-list] Unneeded Qt dependency


From: Nikos Chantziaras
Subject: Re: [Mingw-cross-env-list] Unneeded Qt dependency
Date: Tue, 28 Jun 2011 17:45:10 +0300
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110624 Thunderbird/3.1.11

On 06/21/2011 08:41 AM, Nikos Chantziaras wrote:
On 06/21/2011 08:10 AM, Nikos Chantziaras wrote:
I see that qt.mk lists "libiconv" as a dependency. This is not needed
for Windows. Thiago Macieira mentioned on:

http://lists.qt.nokia.com/pipermail/qt-interest/2010-August/026692.html

"libiconv is not used on Windows."

Though without libiconv, it seems there are link errors anyway. So I'm
puzzled at what's happening here. I'll ask about it on the Qt list.

OK, I now know what's going on. And mingw-cross-env has a problem here. Qt applications will fail silently in the current way Qt is built. I was hit by this bug; a Windows user reported wrong text rendering in my app. The issue is that the application needs to explicitly include the text codec plugins for them to work. In the *.pro file:

  QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs

And somewhere in the program sources:

  #include <QtPlugin>
  Q_IMPORT_PLUGIN(qcncodecs)
  Q_IMPORT_PLUGIN(qjpcodecs)
  Q_IMPORT_PLUGIN(qtwcodecs)
  Q_IMPORT_PLUGIN(qkrcodecs)

The problem here is that when building Qt without specifying the "-no-iconv" configure option, the application will build and appear to run fine without the need to include the plugins as shown above. This is bad (*very* bad), because the application will be unable to convert any text using the QTextCodec classes. For example, in my app I had something like this:

  QTextCodec* cp1252 = QTextCodec::codecForName("Windows-1252");
  // ...
  // Convert from 1252 to Unicode before printing on screen.
  QString str = cp1252->toUnicode(srcText);

The above compiles and runs fine, but it *does not* convert anything! It's a silent bug, and we all know how nasty those are (I wasted a lot of time trying to track down the bug.)

Short answer: mingw-cross-env should build Qt with "-no-iconv". That way, the programmer will get linker errors when trying to build his application. That way, he will know that he *must* include the text codec plugins.

I am attaching a patch with the needed modifications to qt.mk and the qt-test sample program.

Attachment: qt-noiconv.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]