Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-34638

Wrong symbol definitions in QtWinExtras module when building and using a static version of Qt

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.2.0 RC1
    • 5.2.0 Beta1
    • Core: Other
    • None
    • qtwinextras/stable: b6ca71cfb9889a784d3d9ee998974e89faf60bec 7317f4440a9af01feac7758afff8f98e9150dd62

    Description

      Summary:

      In Qt 5.2.0-beta1 on Windows, there is a problem with the definitions of the symbols from the new QtWinExtras module when building and using a static version of the Qt libraries.

      The problem occurs only in QtWinExtras and only with a static version. All other Qt modules work correctly with a static version. QtWinExtras works correctly in the shared version.

      Details:

      An application is compiled on Windows 7 with Qt 5.2.0-beta1. With the prebuilt environment (qt-windows-opensource-5.2.0-beta1-mingw48_opengl-x86-offline.exe), the application compiles and runs fine.

      I have built a static version of Qt 5.2.0-beta1. The application also compiles, links and runs properly.

      I recently tried to take advantage of the new QtWinExtras, namely to add a progress indicator in the task bar. With the prebuilt environment (dynamic linking), it works. With the static build, the application fails to link with undefined symbols:

      g++ -static -static-libgcc -Wl,-s -Wl,-subsystem,windows -mthreads -o QtlMovie.exe object_script.QtlMovie  -lmingw32 -lqtmain -L../Qts// -lQts -L../Qtl// -lQtl -LC:/Qt/Static/5.2.0-beta1/lib -lQt5Multimedia -lstrmiids -lQt5WinExtras -lQt5Widgets -lQt5Network -ldnsapi -LC:/Qt/Static/5.2.0-beta1/plugins/platforms -lqwindows -lwinspool -lshlwapi -lQt5PlatformSupport -lQt5Gui -lcomdlg32 -loleaut32 -limm32 -lwinmm -lglu32 -lopengl32 -lgdi32 -lQt5Core -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 QtlMovie_res.o
      ./QtlMovieMainWindow.o:QtlMovieMainWindow.cpp:(.text+0x105f): undefined reference to `_imp___ZN19QWinTaskbarProgress10setVisibleEb'
      ./QtlMovieMainWindow.o:QtlMovieMainWindow.cpp:(.text+0x1789): undefined reference to `_imp___ZN19QWinTaskbarProgress8setValueEi'
      ./QtlMovieMainWindow.o:QtlMovieMainWindow.cpp:(.text+0x36de): undefined reference to `_imp___ZN5QtWin20isCompositionEnabledEv'
      ./QtlMovieMainWindow.o:QtlMovieMainWindow.cpp:(.text+0x36fd): undefined reference to `_imp___ZN5QtWin22enableBlurBehindWindowEP7QWindow'
      ./QtlMovieMainWindow.o:QtlMovieMainWindow.cpp:(.text+0x3716): undefined reference to `_imp___ZN17QWinTaskbarButtonC1EP7QObject'
      ./QtlMovieMainWindow.o:QtlMovieMainWindow.cpp:(.text+0x3735): undefined reference to `_imp___ZN17QWinTaskbarButton9setWindowEP7QWindow'
      ./QtlMovieMainWindow.o:QtlMovieMainWindow.cpp:(.text+0x3744): undefined reference to `_imp___ZNK17QWinTaskbarButton8progressEv'
      ./QtlMovieMainWindow.o:QtlMovieMainWindow.cpp:(.text+0x3761): undefined reference to `_imp___ZN19QWinTaskbarProgress8setRangeEii'
      c:/qt/qt5.2.0/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: ./QtlMovieMainWindow.o: bad reloc address 0x10 in section `.text$_ZN20QtlMovieEditSettingsD1Ev[__ZN20QtlMovieEditSettingsD1Ev]'
      collect2.exe: error: ld returned 1 exit status
      

      All these symbols belong to QtWinExtras. A quick check shows that libQt5WinExtras.a does exist in the static version.

      It seems that the problem comes from the way QtWinExtras classes and functions are declared when used from an application, not from the static build of Qt. Look at the following evidences.

      First, let's examine an "old" symbol which is correctly referenced in the static version of the application, namely QObject::setObjectName().

      Definition in the shared prebuilt version of Qt:

      PS> nm .\Qt5.2.0\5.2.0-beta1\mingw48_32\lib\libQt5Core.a | Select-String setobjectname
      00000000 I __imp___ZN7QObject13setObjectNameERK7QString
      00000000 T __ZN7QObject13setObjectNameERK7QString
      

      Definition in the static version of Qt:

      PS> nm .\Static\5.2.0-beta1\lib\libQt5Core.a | Select-String setobjectname
      00002d80 T __ZN7QObject13setObjectNameERK7QString
               U __ZN7QObject13setObjectNameERK7QString
               U __ZN7QObject13setObjectNameERK7QString
      

      Reference in the shared built application:

      PS> nm .\build-QtlMovie-Desktop_Qt_5_2_0_MinGW_32bit-Release\QtlMovie\*.o | Select-String setobjectname
               U __imp___ZN7QObject13setObjectNameERK7QString
      

      Reference in the statically built application:

      PS> nm .\build-Win32-Release-Static\QtlMovie\*.o | Select-String setobjectname
               U __ZN7QObject13setObjectNameERK7QString
      

      So, for the symbol QObject::setObjectName(), the references from the application are consistent with the definitions in the corresponding shared vs. static version of the Qt library.

      Now, let's do the same checks on the symbol QtWin::isCompositionEnabled() from the new QtWinExtras.

      Definition in the shared prebuilt version of Qt:

      PS> nm .\Qt5.2.0\5.2.0-beta1\mingw48_32\lib\libQt5WinExtras.a | Select-String isCompositionEnabled
      00000000 I __imp___ZN5QtWin20isCompositionEnabledEv
      00000000 T __ZN5QtWin20isCompositionEnabledEv
      

      Definition in the static version of Qt:

      PS> nm .\Static\5.2.0-beta1\lib\libQt5WinExtras.a | Select-String isCompositionEnabled
               U __ZN5QtWin20isCompositionEnabledEv
      00000270 T __Z26qt_DwmIsCompositionEnabledPi
      00000010 b __ZL24pDwmIsCompositionEnabled
               U __Z26qt_DwmIsCompositionEnabledPi
      00006070 T __ZN5QtWin20isCompositionEnabledEv
      

      Reference in the shared built application:

      PS> nm .\build-QtlMovie-Desktop_Qt_5_2_0_MinGW_32bit-Release\QtlMovie\*.o | Select-String iscompositionenabled
               U __imp___ZN5QtWin20isCompositionEnabledEv
      

      Reference in the statically built application:

      PS> nm .\build-Win32-Release-Static\QtlMovie\*.o | Select-String iscompositionenabled
               U __imp___ZN5QtWin20isCompositionEnabledEv
      

      Here, the reference in the statically built application is identical to the reference in the shared built application. It is inconsistent with the definition in the static version of Qt.

      I insist on the fact that the problem occurs only on symbols from the new QtWinExtras module. So there is something wrong specifically in the way the application refers to these new symbols.

      If you need the full source code of the application, you will find the git repository on SourceForge at git://git.code.sf.net/p/qtlmovie/code qtlmovie-code. The Windows PowerShell script which was used to build the static version of Qt can be found at http://sourceforge.net/p/qtlmovie/code/ci/master/tree/build/windows-build-qt-static.ps1. Details on building the application can be found on http://qtlmovie.sourceforge.net/doc/qtlmovie-build.html.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            thiel2 Thierry Lelegard
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes