[Qt-interest] Qt 2009.02, WinXP mingw32, and OpenGL *static* linking problem

Jens Bache-Wiig jbache at trolltech.com
Fri May 8 09:54:31 CEST 2009


This is indeed a problem in Qt that was identieifed and fixed recently.
It has been fixed for the 4.5.2 release. You can patch it yourself by
declaring qt_win_owndc_required as 'extern' in qwindowsurface_gl.cpp

Jens

"Jens Holzhaeuser" <Jens.Holzhaeuser at gmx.net> wrote in message 
news:20090507175758.GE30677 at zaphod.galacticempire.org.us...
> Hi,
>
> I've done a fair share of (Qt, C++) development on Unix/Linux, but I am
> completely new to this on Windows XP.
> I installed the Qt 2009.02 SDK (http://www.qtsoftware.com/downloads) and
> can compile, (dynamically) link and run my application (which uses 
> OpenGL).
>
> For distribution I'd like to create a statically linked windows 
> executable,
> so I tried the following
>
> * made complete copy of 2009.02\qt and named it 2009.02\qt-static
> * created a new file 2009.02\bin\qtenv-static.bat (from qtenv.bat as a 
> template)
>   to reflect the qt-static paths:
>
>   @echo off
>   rem
>   rem This file is generated
>   rem
>   echo Setting up a MinGW/Qt only environment...
>   echo -- QTDIR set to D:\Qt\2009.02\qt-static
>   echo -- PATH set to D:\Qt\2009.02\qt-static\bin
>   echo -- Adding D:\Qt\2009.02\bin to PATH
>   echo -- Adding %SystemRoot%\System32 to PATH
>   echo -- QMAKESPEC set to win32-g++
>   set QTDIR=D:\Qt\2009.02\qt-static
>   set PATH=D:\Qt\2009.02\qt-static\bin
>   set PATH=%PATH%;D:\Qt\2009.02\bin;D:\Qt\2009.02\mingw\bin
>   set PATH=%PATH%;%SystemRoot%\System32
>   set QMAKESPEC=win32-g++
>
> * edited 2009.02/qt-static/configure.cache from
>
>  -debug-and-release
>  -confirm-license
>  -plugin-sql-sqlite
>  -plugin-sql-odbc
>  -qt-libpng
>  -qt-libjpeg
>  -openssl
>  -opensource
>  -no-incredibuild-xge
>
>  to
>
>  -static
>  -debug-and-release
>  -confirm-license
>  -plugin-sql-sqlite
>  -plugin-sql-odbc
>  -qt-libpng
>  -qt-libjpeg
>  -opensource
>  -no-incredibuild-xge
>
>  (I don't need or have openssl, I added the -static switch)
>
> * then ran "configure -redo" and "mingw32-make sub-src" in 
> 2009.02\qt-static
>   (and a few hours later, then)
> * I get a linker error when I try to compile my own OpenGL application in 
> this new
>   Qt environment. I get the same linker error when I try to make the 
> OpenGL
>   examples that come with Qt ("cd 2009.02\qt-static\examples\opengl" and
>   "mingw32-make"), so I guess I have a fundamental problem here:
>
>   [...]
>   g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc 
>  -mthreads -Wl -Wl,-subsystem,windows -o debug\2dpainting.exe 
> tmp/obj/debug_static/glwidget.o tmp/obj/debug_static/helper.o 
> tmp/obj/debug_static/main.o tmp/obj/debug_static/widget.o 
> tmp/obj/debug_static/window.o tmp/obj/debug_static/moc_glwidget.o 
> tmp/obj/debug_static/moc_widget.o 
> mp/obj/debug_static/moc_window.o  -L"d:\Qt\2009.02\QT-STA~1\lib" -L"d:\Qt\2009.02\QT-STA~1\lib" 
>  -lmingw32 -lqtmaind -lQtOpenGLd -lop
> engl32 -lglu32 -lQtGuid -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool 
>  -lmsimg32 -lQtCored -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 
>  -lws2_32
>   d:\Qt\2009.02\QT-STA~1\lib/libQtGuid.a(qapplication_win.o)(.bss+0x1): In 
> function `ZN5QHashI7QStringiE8freeDataEP9QHashData':
> 
> D:/Qt/2009.02/QT-STA~1/src/gui/../../include/QtCore/../../src/corelib/thread/qbasicatomic.h: 
> multiple definition of `qt_win_owndc_required'
> 
> d:\Qt\2009.02\QT-STA~1\lib/libQtOpenGLd.a(qwindowsurface_gl.o)(.bss+0x0):D:/Qt/2009.02/QT-STA~1/src/opengl/../../include/QtCore/../../src/corelib/tools/qvector.h: 
> first defined here
>    collect2: ld returned 1 exit status
>    mingw32-make[2]: *** [debug\2dpainting.exe] Error 1
>    mingw32-make[2]: Leaving directory 
> `D:/Qt/2009.02/QT-STA~1/examples/opengl/2dpainting'
>    mingw32-make[1]: *** [debug-all] Error 2
>    mingw32-make[1]: Leaving directory 
> `D:/Qt/2009.02/QT-STA~1/examples/opengl/2dpainting'
>    mingw32-make: *** [sub-2dpainting-make_default] Error 2
>
> * Compiling and running other non-OpenGL examples works fine.
>
>
> Apparently two static libs contain definitions for the same symbol
> (`qt_win_owndc_required'). Being unfamiliar with development on Windows, I 
> have no
> idea why that is and how to correct the problem. Can anybody help? 
> Googeling hasn't
> brought up any hints for me.
>
> Thanks,
>
> Jens
>
>
> -- 
> Jens Holzhäuser                                jens.holzhaeuser at gmx.net
> Richmond, Virginia (USA) 




More information about the Qt-interest-old mailing list