Difference between revisions of "LLQtWebKit Win32 Build Instructions"

From Second Life Wiki
Jump to navigation Jump to search
Line 2: Line 2:


== Introduction ==
== 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.
These are instructions for building the Qt/WebKit library (LLQtWebKit) on Windows as well as the test applications (testGL, uBrowser, QtTestApp, Win32GL). They have been tested using Microsoft Visual Studio 2005 (SP2) on Windows XP Service Pack 3 and Qt 4.6.0. It is not known if the same instructions work using other versions of Windows, Microsoft Visual Studio or Qt.
 
== Set up ==
* For clarity, these instructions contain references to example paths and directories. Except where noted, you may replace these with ones of your own choosing although it is generally advisable to choose ones without spaces in them.


== Acquire LLQtWebKit source code ==
== Acquire LLQtWebKit source code ==
Line 9: Line 12:
* A zip file of the source code will be downloaded
* A zip file of the source code will be downloaded
* Extract the contents of the zip file to <code>C:\llqtwebkit</code>
* Extract the contents of the zip file to <code>C:\llqtwebkit</code>
**Note: Different tools have different concepts of "contents" - you should end up with the directories and files in <code>C:\llqtwebkit</code> and not <code>C:\llqtwebkit\llqtwebkit</code>
**Note: Different archiving tools have different concepts of "contents" - you should end up with the directories and files in <code>C:\llqtwebkit</code> and not <code>C:\llqtwebkit\llqtwebkit</code>
* Do not build anything yet - some of the files that were just downloaded will be used to modify the OpenSSL and Qt source code


== Build the open source OpenSSL library ==
== Build the open source OpenSSL library ==
* Make sure a recent version of 'perl' and 'patch' are available on your system.
* Make sure a recent version of '<code>perl</code>' and '<code>patch</code>' are available on your system.
* Download the OpenSSL 0.9.8k tarball from http://openssl.org/source/openssl-0.9.8k.tar.gz
* Download the OpenSSL 0.9.8l tarball from http://openssl.org/source/openssl-0.9.8l.tar.gz
* Extract the contents to <code>C:\openssl-0.9.8k</code>
* Extract the contents to <code>C:\openssl-0.9.8l</code>
** Note: Different tools have different concepts of "contents" - you should end up with the directories and files in <code>C:\openssl-0.9.8k</code> and not <code>C:\openssl-0.9.8k\openssl-0.9.8k</code>
** Note: Different archive tools have different concepts of "contents" - you should end up with the directories and files in <code>C:\openssl-0.9.8l</code> and not <code>C:\openssl-0.9.8l\openssl-0.9.8l</code>
* Open the "Visual Studio 2005 Command Prompt" (Start Menu->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio 2005 Command Prompt)
* 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 - the line endings are broken out of the box on Windows.
* Change to the <code>C:\openssl-0.9.8l</code> directory  
** Copy the OpenSSL patch files from the <code>LLQtWebKit\other_patches</code> directory into the <code>C:\openssl-0.9.8k</code> directory.
* Run these commands:
** Open a command prompt and change to the <code>C:\openssl-0.9.8k</code> directory
** Run this command:
*** <code>patch -p1 < 010-openssl-fix-line-endings.patch</code>
* In the same directory, execute the following commands to build OpenSSL:
** <code>perl Configure VC-WIN32</code>
** <code>perl Configure VC-WIN32</code>
** <code>ms\do_masm</code>
** <code>ms\do_masm</code>
* Patch the <code>ntdll.mak</code> file generated by the previous steps using
* Patch the <code>ntdll.mak</code> file generated by the previous steps (this fixes the DLL manifest settings so that they are compatible with the Second Life client build configuration)
** <code>patch -p1 < 020-openssl-disable-manifest.patch</code>
** Copy the patch file <code>020-openssl-disable-manifest.patch</code> from the <code>llqtwebkit-4.6\patches</code> to <code>C:\openssl-0.9.8l</code>
** Run this command:
*** <code>patch -p1 < 020-openssl-disable-manifest.patch</code>
* Continue to build  
* Continue to build  
** <code>nmake -f ms\ntdll.mak</code>
** <code>nmake -f ms\ntdll.mak</code>
* After a few minutes, the libraries <code>libeay32.dll</code> and <code>ssleay32.dll</code> will be built in the <code>C:\openssl-0.9.8k\out32dll</code> directory - confirm they exist - they will be needed later.
* After a few minutes, the libraries <code>libeay32.dll</code> and <code>ssleay32.dll</code> will be built in the <code>C:\openssl-0.9.8l\out32dll</code> directory - confirm they exist - they will be needed later.


== Build the open source version of Qt 4.5.2 using Microsoft Visual Studio ==
== Build the open source version of Qt 4.6.0 using Microsoft Visual Studio ==
=== Downloading and patching the Qt source ===
=== Acquire the Qt 4.6.0 source with our patches ===
* 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)
* Our clone of Qt is available here: http://gitorious.org/+lindenqt/qt/lindenqt
* Extract the contents of the tarball into <code>C:\Qt</code>
* Download the source by clicking on the "lindenqt" branch under "Branches:" and then using the "Download lindenqt as tar.gz" link on the right hand side of the page
** It's a large download - over 100MB - so it may take some time
** Alternately, if you prefer you can clone the repository with git using the "clone" link on the page -- details of this are left as an exercise to the reader
* Extract the contents of the tarball into <code>C:\qt-lindenqt</code>
* This may take some as the archive contains a lot of files
* This may take some as the archive contains a lot of files
** Note: Different tools have different concepts of "contents" - you should end up with the directories and files in <code>C:\Qt\qt-all-opensource-src-4.5.2</code> and not <code>C:\Qt\qt-all-opensource-src-4.5.2\qt-all-opensource-src-4.5.2</code>  
** Note: Different tools have different concepts of "contents" - you should end up with the directories and files in <code>C:\qt-lindenqt</code> and not <code>C:\qt-lindenqt\qt-lindenqt</code>  
** 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.).
** Note: using Cygwin's <code>tar</code> command might not work.  It may result in an '''Access is Denied''' error when running configure below. If so, try using WinZip, WinRAR or some other tool instead.
* Copy the <code>.patch</code> files that are required from the <code>C:\llqtwebkit\qt_patches\</code> to the <code>C:\Qt\qt-all-opensource-src-4.5.2</code> 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 <code>C:\Qt\qt-all-opensource-src-4.5.2</code> directory
* Apply the patches in the order indicated by the number in the filename - 002, 007, 008 etc.
* For each <code>.patch</code> file, run the following command:
<code>patch -p1 < $PATCH_NAME</code>
* where <code>$PATCH_NAME</code> is the filename of the patch file


=== Configure Qt ===
=== Configure Qt ===
* Change to the <code>C:\Qt\qt-all-opensource-src-4.5.2</code> directory  
* If it's not open already, open the "Visual Studio 2005 Command Prompt" (Start Menu->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio 2005 Command Prompt)
* Change to the <code>C:\qt-lindenqt</code> directory  
* Run this command:  
* Run this command:  
  <code>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</code>
  <code>configure -debug-and-release -no-qt3support -no-phonon -no-phonon-backend -prefix C:\qt-lindenqt -qt-libjpeg -qt-libpng -openssl-linked -I C:\openssl-0.9.8l\include -L C:\openssl-0.9.8l\out32dll</code>
* When you are asked if you want to use the Commercial or Open Source version type <code>o</code> to select Open Source and press <enter>
* When you are asked if you want to use the Commercial or Open Source version type <code>o</code> to select Open Source and press the Enter key
* When the license agreement appears, if you agree type <code>y</code> <enter>
* When the license agreement appears, if you agree type <code>y</code> the Enter key
* This operation takes around 10-15 minutes on a typical development system
* This operation takes around 10-15 minutes on a typical development system


=== Build Qt ===
=== Build Qt ===
* Change to the <code>C:\Qt\qt-all-opensource-src-4.5.2</code> directory  
* Change to the <code>C:\qt-lindenqt</code> directory  
* Run this command:
* Run this command:
  <code>nmake sub-src</code>
  <code>nmake sub-src</code>
* This operation takes around 1-2 hours on a typical development system
* This operation takes around 1-2 hours on a typical development system
* After building Qt the release and debug libraries and dlls will be in <code>C:\Qt\qt-all-opensource-src-4.5.2\lib</code>
* After building Qt, the release and debug libraries and dlls will be in <code>C:\qt-lindenqt\lib</code>


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


== Build LLQtWebKit ==
== Build LLQtWebKit ==
Line 133: Line 129:
  ..\GL\qttestapp.exe
  ..\GL\qttestapp.exe
* If you want to build the debug version, use <code>qmake CONFIG+=debug</code> instead and run <code>nmake clean</code> first
* If you want to build the debug version, use <code>qmake CONFIG+=debug</code> instead and run <code>nmake clean</code> first
=== Win32GL ===
* Edit the path variables at the top of the <code>C:\llqtwebkit\tests\win32gl\copy_files.bat</code> directory to reflect the location of your OpenSSL, Qt and LLQtWebKit files.
* Run the <code>C:\llqtwebkit\tests\win32gl\copy_files.bat</code>
* Open the <code>C:\llqtwebkit\tests\win32gl\win32gl.sln</code> MSVC solution file
* Select <code>Release</code> configuration
* Build and run as normal
== Win32 Helper batch files ==
* There are some helper batch files for Windows developers that may prove useful.
* You will very likely need to configure settings at the top of each one to match the location of the files and directories on your system.
* They do not do much error checking so make sure you understand the ramifications of any changes you make.
* A useful pattern is to edit them so they only do what you need at that moment - build release LLQtWebKit and testGL for example - then revert them when you're finished.
=== Build LLQtWebKit and test apps ===
* Now you have built LLQtWebKit by hand, I'll point out this batch file which does it for you.
* <code>C:\llqtwebkit\make_all.bat</code> is a very simple batch file that will clean and build release and debug versions of LLQtWebKit and then clean and build release version of the test apps (except Win32GL).
* You will need to modify the GL_COMPONENT_DIR variable near the top that sets the location of the GLUT and GLUI build files.
* You almost certainly will want to run this batch file from a Qt command prompt as described above since various Qt directories need to be in the path.
=== Generate a directory tree compatible with the Second Life client build system ===
* <code>C:\llqtwebkit\copy_llqtwebkit.bat</code> is a batch file that:
** Generates a directory tree containing LLQtWebKit header and libraries along with the necessary Qt run time files that are required by the Second Life client.
** Builds a <code>tar.bz2 </code> archive and associated MD5 sum that can be used in the LLQtWebKit section of the Second Life client <code>install.xml</code> configuration file.


== Notes ==
== Notes ==

Revision as of 15:45, 12 March 2010

<<< 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, Win32GL). They have been tested using Microsoft Visual Studio 2005 (SP2) on Windows XP Service Pack 3 and Qt 4.6.0. It is not known if the same instructions work using other versions of Windows, Microsoft Visual Studio or Qt.

Set up

  • For clarity, these instructions contain references to example paths and directories. Except where noted, you may replace these with ones of your own choosing although it is generally advisable to choose ones without spaces in them.

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 contents of the zip file to C:\llqtwebkit
    • Note: Different archiving tools have different concepts of "contents" - you should end up with the directories and files in C:\llqtwebkit and not C:\llqtwebkit\llqtwebkit

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.8l tarball from http://openssl.org/source/openssl-0.9.8l.tar.gz
  • Extract the contents to C:\openssl-0.9.8l
    • Note: Different archive tools have different concepts of "contents" - you should end up with the directories and files in C:\openssl-0.9.8l and not C:\openssl-0.9.8l\openssl-0.9.8l
  • Open the "Visual Studio 2005 Command Prompt" (Start Menu->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio 2005 Command Prompt)
  • Change to the C:\openssl-0.9.8l directory
  • Run these commands:
    • perl Configure VC-WIN32
    • ms\do_masm
  • Patch the ntdll.mak file generated by the previous steps (this fixes the DLL manifest settings so that they are compatible with the Second Life client build configuration)
    • Copy the patch file 020-openssl-disable-manifest.patch from the llqtwebkit-4.6\patches to C:\openssl-0.9.8l
    • Run this command:
      • patch -p1 < 020-openssl-disable-manifest.patch
  • Continue to build
    • 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.8l\out32dll directory - confirm they exist - they will be needed later.

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

Acquire the Qt 4.6.0 source with our patches

  • Our clone of Qt is available here: http://gitorious.org/+lindenqt/qt/lindenqt
  • Download the source by clicking on the "lindenqt" branch under "Branches:" and then using the "Download lindenqt as tar.gz" link on the right hand side of the page
    • It's a large download - over 100MB - so it may take some time
    • Alternately, if you prefer you can clone the repository with git using the "clone" link on the page -- details of this are left as an exercise to the reader
  • Extract the contents of the tarball into C:\qt-lindenqt
  • This may take some as the archive contains a lot of files
    • Note: Different tools have different concepts of "contents" - you should end up with the directories and files in C:\qt-lindenqt and not C:\qt-lindenqt\qt-lindenqt
    • Note: using Cygwin's tar command might not work. It may result in an Access is Denied error when running configure below. If so, try using WinZip, WinRAR or some other tool instead.

Configure Qt

  • If it's not open already, open the "Visual Studio 2005 Command Prompt" (Start Menu->Microsoft Visual Studio 2005->Visual Studio Tools->Visual Studio 2005 Command Prompt)
  • Change to the C:\qt-lindenqt directory
  • Run this command:
configure -debug-and-release -no-qt3support -no-phonon -no-phonon-backend -prefix C:\qt-lindenqt -qt-libjpeg -qt-libpng -openssl-linked -I C:\openssl-0.9.8l\include -L C:\openssl-0.9.8l\out32dll
  • When you are asked if you want to use the Commercial or Open Source version type o to select Open Source and press the Enter key
  • When the license agreement appears, if you agree type y the Enter key
  • This operation takes around 10-15 minutes on a typical development system

Build Qt

  • Change to the C:\qt-lindenqt 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 and dlls will be in C:\qt-lindenqt\lib

Configure a Qt runtime environment

  • Copy the OpenSSL dynamic libraries (C:\openssl-0.9.8l\out32dll\libeay32.dll and C:\openssl-0.9.8l\out32dll\ssleay32.dll) to the Qt binary directory (C:\qt-lindenqt\bin)
  • Create the file C:\qt-lindenqt\bin\qt-vars.bat and put the following in it:
@echo off
echo Setting up a Qt environment...
set QTDIR=C:\qt-lindenqt
set PATH=C:\qt-lindenqt\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-lindenqt\bin\qt-vars.bat"
Start in: C:\qt-lindenqt
  • Rename the shortcut to "Qt Linden Command Prompt".
  • Test it by opening the prompt and typing
qmake --version
  • Confirm that the Qt version displayed is 4.6.0

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

Win32GL

  • Edit the path variables at the top of the C:\llqtwebkit\tests\win32gl\copy_files.bat directory to reflect the location of your OpenSSL, Qt and LLQtWebKit files.
  • Run the C:\llqtwebkit\tests\win32gl\copy_files.bat
  • Open the C:\llqtwebkit\tests\win32gl\win32gl.sln MSVC solution file
  • Select Release configuration
  • Build and run as normal

Win32 Helper batch files

  • There are some helper batch files for Windows developers that may prove useful.
  • You will very likely need to configure settings at the top of each one to match the location of the files and directories on your system.
  • They do not do much error checking so make sure you understand the ramifications of any changes you make.
  • A useful pattern is to edit them so they only do what you need at that moment - build release LLQtWebKit and testGL for example - then revert them when you're finished.

Build LLQtWebKit and test apps

  • Now you have built LLQtWebKit by hand, I'll point out this batch file which does it for you.
  • C:\llqtwebkit\make_all.bat is a very simple batch file that will clean and build release and debug versions of LLQtWebKit and then clean and build release version of the test apps (except Win32GL).
  • You will need to modify the GL_COMPONENT_DIR variable near the top that sets the location of the GLUT and GLUI build files.
  • You almost certainly will want to run this batch file from a Qt command prompt as described above since various Qt directories need to be in the path.

Generate a directory tree compatible with the Second Life client build system

  • C:\llqtwebkit\copy_llqtwebkit.bat is a batch file that:
    • Generates a directory tree containing LLQtWebKit header and libraries along with the necessary Qt run time files that are required by the Second Life client.
    • Builds a tar.bz2 archive and associated MD5 sum that can be used in the LLQtWebKit section of the Second Life client install.xml configuration file.

Notes

  • To enable a run time console for the test applications add a CONFIG+=console line to the qmake line.
  • 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