LLQtWebKit Win32 Build Instructions

From Second Life Wiki
Revision as of 01:43, 2 September 2009 by Callum Linden (talk | contribs)
Jump to navigation Jump to search

<<< Back to LLQtWebKit main page

Introduction

These are instructions for building the Qt/WebKit library (LLQtWebKit) on Windows as well as the test applications (testGL, uBrowser, QtTestApp). They have been tested using Microsoft Visual Studio 2005 (SP2) on Windows XP Service Pack 2 and Qt 4.5.2. It is not known if the same instructions work on Windows Vista or Windows 7 or using other versions of Microsoft Visual Studio or Qt.

Build the open source OpenSSL library

  • Make sure a recent version of 'perl' and 'patch' are available on your system.
  • Download the OpenSSL 0.9.8k tarball from http://openssl.org/source/openssl-0.9.8k.tar.gz
  • Extract the contents to C:\openssl-0.9.8k
  • Open the "Visual Studio 2005 Command Prompt" (Start Menu->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio 2005 Command Prompt)
  • Patch the OpenSSL distribution - it is broken out of the box on Windows. Copy the following lines into a file called fix.patch in the C:\openssl-0.9.8k\util\ directory:
*** Source: http://marc.info/?l=openssl-dev&m=107628900919852&q=raw
*** openssl-0.9.7c/util/mk1mf.pl	Fri Mar 14 17:29:18 2003
--- openssl-0.9.7c-miket/util/mk1mf.pl	Sat Feb  7 21:58:57 2004
***************
*** 485,490 ****
--- 485,495 ----
  	chop;
  
  	($key,$val)=/^([^=]+)=(.*)/;
+ 	
+ 	# On some Windows machines, $val has linefeeds at the end, which confuses
+ 	# subsequent code in this file. So we strip all whitespace at the end.
+     $val =~ s/\s+$//;
+     
  	if ($key eq "RELATIVE_DIRECTORY")
  		{
  		if ($lib ne "")

then run this command from the C:\openssl-0.9.8k\util\ directory:

patch -p0 mk1mf.pl < fix.patch
  • Execute the following commands to build OpenSSL:
cd C:\openssl-0.9.8k
perl Configure VC-WIN32
ms\do_masm
nmake -f ms\ntdll.mak
  • After a few minutes, the libraries libeay32.dll and ssleay32.dll will be built in the C:\openssl-0.9.8k\out32dll directory - confirm they exist - they will be needed later.

Acquire LLQtWebKit source code

  • In a Web browser, navigate to http://hg.secondlife.com/llqtwebkit/
  • Select "get source->zip" from menu
  • A zip file of the source code will be downloaded
  • Extract the files in the zip to C:\llqtwebkit
  • Do not build anything yet - some of the files that were just downloaded will be used to modify the Qt source code

Build the open source version of Qt 4.5.2 using Microsoft Visual Studio

Downloading and patching the Qt source

  • Download the Qt 4.5.2 source from ftp://ftp.qtsoftware.com/qt/source/qt-all-opensource-src-4.5.2.tar.gz (Approximately 125MB)
  • Extract the tarball into C:\Qt (Note: using Cygwin's tar command might not work. It results in an Access is Denied error when running configure below. Use WinZip or some other tool instead.).
  • This may take some as the archive contains a lot of files
  • You should now have a directory C:\Qt\qt-all-opensource-src-4.5.2
  • Review the file C:\llqtwebkit\qt_patches\merged_into_qt to determine which patches need to be applied. Some patches are no longer needed with Qt 4.5.2.
  • Copy the .patch files that are required from the C:\llqtwebkit\qt_patches\ to the C:\Qt\qt-all-opensource-src-4.5.2 directory
  • If you do not have an MSVC command prompt open, open one now. (Start Menu->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio 2005 Command Prompt)
  • Change to the C:\Qt\qt-all-opensource-src-4.5.2 directory
  • For each .patch file, run the following command:
patch -p1 < $PATCH_NAME
  • where $PATCH_NAME is the filename of the patch file

Configure Qt

  • Change to the C:\Qt\qt-all-opensource-src-4.5.2 directory
  • Run this command:
configure -debug-and-release -no-qt3support -prefix C:\Qt\qt-all-opensource-src-4.5.2 -qt-libjpeg -qt-libpng -openssl-linked -I C:\openssl-0.9.8k\include -L C:\openssl-0.9.8k\out32dll
  • When you are asked if you want to use the Commercial or Open Source version type o to select Open Source and press <enter>
  • When the license agreement appears, if you agree type y <enter>
  • This operation takes around 10-15 minutes on a typical development system

Build Qt

  • Change to the C:\Qt\qt-all-opensource-src-4.5.2 directory
  • Run this command:
nmake sub-src
  • This operation takes around 1-2 hours on a typical development system
  • After building Qt the release and debug libraries will be in C:\Qt\qt-all-opensource-src-4.5.2\lib

Configure a Qt runtime environment

  • Copy the OpenSSL dynamic libraries (C:\openssl-0.9.8k\out32dll\libeay32.dll and C:\openssl-0.9.8k\out32dll\ssleay32.dll) to the Qt binary directory (C:\qt\qt-all-opensource-src-4.5.2\bin)
  • Create the file C:\Qt\qt-all-opensource-src-4.5.2\bin\qt-vars.bat and put the following in it:
@echo off
echo Setting up a Qt environment...
set QTDIR=C:\Qt\qt-all-opensource-src-4.5.2
set PATH=C:\Qt\qt-all-opensource-src-4.5.2\bin;%PATH%
set QMAKESPEC=win32-msvc2005
call "C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"
  • Make a shortcut to qt-vars.bat on your desktop
  • Right-click on the shortcut and set the following properties:
Target: %COMSPEC% /k "C:\Qt\qt-all-opensource-src-4.5.2\bin\qt-vars.bat"
Start in: C:\Qt\qt-all-opensource-src-4.5.2
  • Rename the shortcut to "Qt 4.5.2 Command Prompt".
  • Test it by opening the prompt and typing
qmake --version
  • Confirm that the Qt version displayed is 4.5.2


Build LLQtWebKit

  • Launch the Qt command prompt and enter the following in the command prompt:
cd C:\llqtwebkit
qmake CONFIG-=debug
nmake
  • This operation takes just a few seconds on a typical development system
  • If you want to build the debug version of LLQtWebKit, use qmake CONFIG+=debug instead
  • Now LLQtWebKit is built and can be used in the Second Life viewer.
  • If you want to build the test applications, follow the next steps:

Acquire test application dependencies

Glut

  • Glut is a cross-platform library that manages OpenGL state and creation/destruction of OpenGL windows
  • The author provides a library and header for Windows so you do not have to build them yourself
  • Download the library and headers from http://www.xmission.com/~nate/glut/glut-3.7.6-bin.zip
  • Extract the contents of the zip to a new folder called C:\llqtwebkit\tests\GL

GLUI

  • Glut is a cross-platform library that renders UI components in the uBrowser test application
  • The author does not provide libraries for Windows so you have to build them yourself.
  • Download the source code from http://sourceforge.net/projects/glui/files/Source/2.36/glui-2.36.zip/download
  • Extract to C:\glui-2.36
  • Copy glut.h from C:\llqtwebkit\tests\GL to C:\glui-2.36\src\include\GL as it is required to build GLUI
  • Open C:\glui-2.36\src\msvc\glui.sln and let Visual Studio convert the project
  • Select "Release" configuration of "_glui library" project and build it as normal
  • Copy the GLUI header (C:\glui-2.36\src\include\GL\glui.h) to C:\llqtwebkit\tests\GL
  • Copy the GLUI library you just built (C:\glui-2.36\src\msvc\lib\glui32.lib) to C:\llqtwebkit\tests\GL

Build test applications

testGL

  • Open the Qt command prompt using the shortcut you made and enter the following:
cd C:\llqtwebkit\tests\testgl
qmake CONFIG-=debug
nmake
..\GL\testgl.exe
  • If you want to build the debug version, use qmake CONFIG+=debug instead and run nmake clean first

uBrowser

  • Open the Qt command prompt using the shortcut you made and enter the following:
cd C:\llqtwebkit\tests\ubrowser
qmake CONFIG-=debug
nmake
..\GL\ubrowser.exe
  • Important: glui.h contains a pragma that forces the build to always link against the release version - glut32.lib - instead of the debug version. This means building a debug version of uBrowser is currently broken.

QtTestApp

  • Open the Qt command prompt using the shortcut you made and enter the following:
cd C:\llqtwebkit\tests\qttestapp
qmake CONFIG-=debug
nmake
..\GL\qttestapp.exe
  • If you want to build the debug version, use qmake CONFIG+=debug instead and run nmake clean first

Notes

  • Make sure all libraries and applications are built as Multi-threaded Dll or Multi-threaded debug dll. In Visual Studio this is in Properties->configuration->c/c++->code generation->runtime library
  • Make sure you do not mix release and debug versions of libraries and applications