QtWinExtras in 5.2.0-beta1 and static link : wrong symbols
-
Hello,
My 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.
Now, compare the symbols in libQt5WinExtras.a from the shared and static versions, respectively;
@
PS C:\Qt> nm .\Qt5.2.0\5.2.0-beta1\mingw48_32\lib\libQt5WinExtras.a | Select-String enableblur00000000 I __imp___ZN5QtWin22enableBlurBehindWindowEP7QWindowRK7QRegion
00000000 T __ZN5QtWin22enableBlurBehindWindowEP7QWindowRK7QRegion
00000000 I __imp___ZN5QtWin22enableBlurBehindWindowEP7QWindow
00000000 T __ZN5QtWin22enableBlurBehindWindowEP7QWindowPS C:\Qt> nm .\Static\5.2.0-beta1\lib\libQt5WinExtras.a | Select-String enableblur
00000230 T __Z28qt_DwmEnableBlurBehindWindowP6HWND__PK17qt_DWM_BLURBEHIND
00000000 B _pDwmEnableBlurBehindWindow
U __Z28qt_DwmEnableBlurBehindWindowP6HWND__PK17qt_DWM_BLURBEHIND
00006000 T __ZN5QtWin22enableBlurBehindWindowEP7QWindow
00005f60 T __ZN5QtWin22enableBlurBehindWindowEP7QWindowRK7QRegion
@We can see for instance that the statically compiled application has a reference to symbol _imp___ZN5QtWin22enableBlurBehindWindowEP7QWindow. This symbol exists in the shared version of the library but is slightly different in the static version. The same kind of difference exist for all other undefined symbols.
Note that this phenomenom exists only in the QtWinExtras module. The rest of the application linked well with the static version before trying to use QtWinExtras.
For reference, the configure command to build the static version was:
@
configure.bat -static -debug-and-release -platform win32-g++ -prefix $QtDir -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -no-openssl -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests
@Since QtWinExtras is new, isn't there something wrong in its declarations for static compilation ?
-Thierry -
I reported it as a bug. It was acknowledged and fixed for 5.2.0 RC1.
See https://bugreports.qt-project.org/browse/QTBUG-34638