Monday 31 January 2011

How to Move a Qt Install / Library (Version 2)

This took me a fair while to work out and it has saved me a lot of time since. It's a script to automatically update a Qt installation to new locations.

To use
1) Copy the code into set-env.bat and patch-qt.bat respectively.
2) Place them in the top directory.
3) Run set-env.bat from a command prompt.

I assume that you have the following directory structure.

home /
+ dep/
+ set-env.bat
+ patch-qt.bat
++ qt/
+++ bin/
+++ gdb-arm-symbianelf/
+++ lib/
+++ mingw/
+++ qt/
+++ share/

Platform - Windows XP
Qt - 4.6.2

set-env.bat (double click code to select all)

@echo off

echo Setting up variable HOME
set HOME=%cd%

echo Clearing variable PATH
set PATH=

echo Setting up Qt
set QTDIR=%HOME%\dep\qt\qt
set QMAKESPEC=%HOME%\dep\qt\qt\mkspecs\win32-g++
set PATH=%PATH%;%QTDIR%\qt\bin
set PATH=%PATH%;%QTDIR%\bin
rem You need this to have access to 'findstr' for patch-qt.bat.
set PATH=%PATH%;c:\windows\system32
call patch-qt.bat


patch-qt.bat (double click code to select all)

@echo off

rem Specify that variables are local.
setlocal

rem Get the old qt directory.
for /f "tokens=3" %%i in ('findstr QT_SOURCE_TREE dep\qt\qt\.qmake.cache') do set oldQtDir=%%i

rem Get the new qt directory
set newQtDir=%cd%\dep\qt\qt

rem Go to the directory with qpatch.exe.
cd dep\qt\bin

rem Patch.
qpatch.exe files-to-patch-windows %oldQtDir% %newQtDir%

rem Return to the previous directory.
cd ../../../..

rem Display a message to alleviate concern about the warning.
echo Binh: I don't know how to fix the above warning. Should be okay for now.

rem Specify that variables are global.
endlocal


Related Links

2 comments:

  1. Hey Binh,

    Wish I had known this :)

    Just been putting together a blog article of my own about building QT. Thought you might be interested:

    http://bigangrydog.blogspot.com/2011/02/building-nokia-qt-sdk-and-making-phonon.html

    I've waisted a load of time re-building QT because I'd unpack in a temporary location.

    ReplyDelete
  2. Hi Andy,

    Just finished reading your article. Thanks for putting together such an informative piece!

    ReplyDelete