Bug 56723

Summary: [Qt] Linking error when tryng to build Qt Webkit on Windows
Product: WebKit Reporter: Nancy Piedra <nancy.piedra>
Component: New BugsAssignee: Nancy Piedra <nancy.piedra>
Status: RESOLVED FIXED    
Severity: Normal CC: abecsi, laszlo.gombos, mgtsai, ossy
Priority: P3 Keywords: Qt
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows XP   
Attachments:
Description Flags
Windows XP linking errors
none
Change to qwebkitglobal.h
none
Change to webcore.pro to export qtwebkit symbols
none
Fixes linking errors in Qt Webkit Windows MinGW build.
none
Link error while --3d-canvas option is enabled none

Description Nancy Piedra 2011-03-20 05:21:24 PDT
Created attachment 86281 [details]
Windows XP linking errors

When trying to build Qt Webkit on Windows XP using MinGW, I get linking errors.  I've attached the error output.

I looked through exiting bugs and didn't see one for this.

I followed the instruction here and built using MinGW:
http://trac.webkit.org/wiki/BuildingQtOnWindows
Comment 1 Nancy Piedra 2011-03-20 05:25:04 PDT
To determine whether the problem is due to the setting of the QWEBKIT_EXPORT macro, I added the following two lines to qwebkitglobal.h.
#define QT_MAKEDLL
#define BUILDING_WEBKIT

By doing the above, I was able to get it to link.

But I could not figure out how to set these through the .pro/pri files properly.  Still working on that.
Comment 2 Nancy Piedra 2011-03-20 06:23:58 PDT
The log shows I used c:\Qt\2010.05 but the same problem exists with C:\Qt\4.7.2.
Comment 3 Nancy Piedra 2011-03-20 18:03:15 PDT
Created attachment 86286 [details]
Change to qwebkitglobal.h

This change seems to fix the problem.  Need to check other builds to make sure it doesn't cause any regression.
Comment 4 Nancy Piedra 2011-03-21 09:43:16 PDT
After speaking with Laszlo Gombos, this seems like qt layering violations we may be able to fix.  I will start looking at that and seeing if I can instead submit patches for the layering violations.
Comment 5 Laszlo Gombos 2011-03-23 19:22:26 PDT
*** Bug 55050 has been marked as a duplicate of this bug. ***
Comment 6 Nancy Piedra 2011-03-24 05:57:07 PDT
Created attachment 86760 [details]
Change to webcore.pro to export qtwebkit symbols

This patch sets the BUILDING_WEBKIT & QT_MAKEDLL macros which in turn will define the QTWEBKIT_EXPORT macro as follows:
#define QWEBKIT_EXPORT Q_DECL_EXPORT

This patch also solves the problem.
Comment 7 Andras Becsi 2011-03-25 05:55:40 PDT
(In reply to comment #6)
> Created an attachment (id=86760) [details]
> Change to webcore.pro to export qtwebkit symbols
> 
> This patch sets the BUILDING_WEBKIT & QT_MAKEDLL macros which in turn will define the QTWEBKIT_EXPORT macro as follows:
> #define QWEBKIT_EXPORT Q_DECL_EXPORT
> 
> This patch also solves the problem.

LGTM.

Ossy could you check whether this also works on your setup?


Nancy, please upload a patch with a ChangeLog for the change and set the r? flag if you'd like the patch to get into trunk and to let the EWS' process it.

For more information see: http://trac.webkit.org/wiki/QtWebKitContrib
Comment 8 Csaba Osztrogonác 2011-03-25 06:38:35 PDT
I tried it, and it works on my Windows machine with MinGW.

Laszlo, have you got any objection against Nancy's fix? 
(apart from missing ChangeLog)
Comment 9 Nancy Piedra 2011-03-25 08:06:26 PDT
Created attachment 86943 [details]
Fixes linking errors in Qt Webkit Windows MinGW build.

Add patch for review.
Comment 10 Joseph Tsai 2011-03-27 09:29:02 PDT
Created attachment 87075 [details]
Link error while --3d-canvas option is enabled

(In reply to comment #9)
> Created an attachment (id=86943) [details]
> Fixes linking errors in Qt Webkit Windows MinGW build.

For building QtWebKit with applying Nancy's patch and WebGL supported (by enabling --3d-canvas option), other undefined references occur again. These undefined references are all about OpenGL functions. (i.e. glDeleteTextures@8)

After digging in the building process, I found that these undefined references should be declared in -lopengl32 option (mingw/lib/libopengl32.a). When building QtWebKit4.dll, the linking option -lopengl32 is before -lwebcore, and the undefined references in libwebcore.a miss their linkage.

For quick workaround, I appended -lopengl32 behind the LIBS variable in Source/WebCore/WebCore.pri:

--------------------------------------
--- WebCore.pri.orig	2011-03-26 18:01:54.000000000 +0800
+++ WebCore.pri	2011-03-27 23:51:14.000000000 +0800
@@ -368,7 +368,7 @@
         POST_TARGETDEPS += $${pathToWebCoreOutput}$${QMAKE_DIR_SEP}$${WEBCORE_TARGET}.lib
     } else {
         QMAKE_LIBDIR = $$pathToWebCoreOutput $$QMAKE_LIBDIR
-        LIBS = -l$$WEBCORE_TARGET $$LIBS
+        LIBS = -l$$WEBCORE_TARGET $$LIBS -lopengl32
         POST_TARGETDEPS += $${pathToWebCoreOutput}$${QMAKE_DIR_SEP}lib$${WEBCORE_TARGET}.a
     }
--------------------------------------

And the building is passed.
Comment 11 Joseph Tsai 2011-03-27 10:00:14 PDT
> For building QtWebKit with applying Nancy's patch and WebGL supported (by enabling --3d-canvas option), other undefined references occur again. These undefined references are all about OpenGL functions. (i.e. glDeleteTextures@8)

The building command that I used:

perl Tools\Scripts\build-webkit --qt --3d-canvas --release
Comment 12 Csaba Osztrogonác 2011-03-28 04:43:56 PDT
Comment on attachment 86943 [details]
Fixes linking errors in Qt Webkit Windows MinGW build.

r=me
Comment 13 Csaba Osztrogonác 2011-03-28 04:55:02 PDT
Comment on attachment 86943 [details]
Fixes linking errors in Qt Webkit Windows MinGW build.

Landed in http://trac.webkit.org/changeset/82102.

Please don't forget to add bug number to the ChangeLog next time.
Comment 14 Nancy Piedra 2011-03-28 05:30:18 PDT
(In reply to comment #11)
> > For building QtWebKit with applying Nancy's patch and WebGL supported (by enabling --3d-canvas option), other undefined references occur again. These undefined references are all about OpenGL functions. (i.e. glDeleteTextures@8)
> The building command that I used:
> perl Tools\Scripts\build-webkit --qt --3d-canvas --release

Joseph - I can create a separate bug for this and see about fixing it.  If you already created the bug, let me know the number.
Comment 15 Joseph Tsai 2011-03-28 05:41:46 PDT
(In reply to comment #14)
> (In reply to comment #11)
> > The building command that I used:
> > perl Tools\Scripts\build-webkit --qt --3d-canvas --release
> 
> Joseph - I can create a separate bug for this and see about fixing it.  If you already created the bug, let me know the number.

I have not created any bug report about this issue yet.
Comment 16 Andras Becsi 2011-03-28 05:44:04 PDT
(In reply to comment #14)
> (In reply to comment #11)
> > > For building QtWebKit with applying Nancy's patch and WebGL supported (by enabling --3d-canvas option), other undefined references occur again. These undefined references are all about OpenGL functions. (i.e. glDeleteTextures@8)
> > The building command that I used:
> > perl Tools\Scripts\build-webkit --qt --3d-canvas --release
> 
> Joseph - I can create a separate bug for this and see about fixing it.  If you already created the bug, let me know the number.

I already created one and am preparing a patch for the issue:

https://bugs.webkit.org/show_bug.cgi?id=57225