How to compile ClientServer module on Windows platform

Prerequisites

  1. Working environment installed as described in How to install COOLFluiD on Windows XP
  2. At least Qt 4.5 open source edition (link below)
  3. ClientServer module needs COOLFluiD kernel librairies to compile and work

Compile Qt

Introduction

It is possible to get a precompiled version of Qt. But it is compiled using MinGW, which makes Qt totally unusable with Microsoft Visual C++. Qt has to be recompiled using Visual C++.

Compiling Qt is a process that eats time (several hours) and disk space (about 5 GB, more in 64 bits). This howto explains how to compile a minimalist Qt capable to compile the ClientServer module. To achieve this, the following parts will be skipped:

  •  Tools (note that qmake and moc tools are compiled anyway, they are used to compile Qt itself)
  • Examples
  • Demos
  • Docs
  • Translations (translation files for tools)
  • Qt3 support

Note that examples and demos sources will be copied to the final installation directory. API documentation will be available in HTML format.

Compilation

  1. Create C:\Qt\4.5.2 directory
  2. Download Qt sources  here
  3. Unzip the archive to C:\tmp
  4. Copy the "mkspecs" directory from unzipped directory to C:\Qt\4.5.2
  5. Launch the Visual Studio command prompt (typically Start > All programs > Microsoft Visual C++ 2008 Express edition > Visual Studio Tools > Visual Studion 2008 Command prompt).
  6. Go to the unzipped directory
  7. Do
    $> configure -prefix "C:\Qt\4.5.2" -platform win32-msvc2008 -opensource -fast -no-qt3support
    
    Where:
    1. prefix option gives the directory where Qt will be installed to.
    2. platform option defines the platform Qt will be compiled for (here Visual C++ 2008).
    3. opensource option defines the license. Note that Qt open source edition only supports the Express edition of Visual C++.
    4. fast option allows to skip some parts of Qt
    5. no-qt3support option disables Qt3 support.

You have to accept the LGPL license to continue. The configuration step takes a few minutes.

  1. Once the configuration is finished, go to the unzipped directory with Windows Explorer. Find the file "project.pro" and open it with a text editor. Find a line similar to:
    QT_BUILD_PARTS = libs tools examples demos docs translations
    
    Comment to keep only "libs", like this:
    QT_BUILD_PARTS = libs # tools examples demos docs translations
    
  2. Save the file and go back to the command prompt. Do:
    $> nmake
    
    This step takes from one to three hours (or more), depending on your hardware configuration.
  3. When compilation is done, install Qt to the destination directory:
    $> nmake install
    

Final step

Add Qt bin directory to the path environment variable

  1. Right-click on the "My computer" icon on the desktop and choose "Properties" (or do the shortcut <Windows key> + <Break>)
  2. Click on the "Environment variables" button in the "Advanced" tab
  3. In "System variables", double click on Path variable and append ";C:\Qt\4.5.2\bin" to the value (don't forget the semi-colon!)
  4. Close the windows by clicking on "Ok".

Launch a new Visual Studio command prompt. If the system can find Qt, the command:

$> qmake -version

Should print something like:

QMake version 2.01a
Using Qt version 4.5.2 in C:\Qt\4.5.2\lib

Test Qt installation

Create a directory with any name you want in C:\tmp. Create in this directory a CXX file with the following code:

#include <QtGui>

int main(int argc, char * argv[])
{
 QApplication app(argc, argv);
 QMessageBox::information(NULL, "Testing Qt", "If you see this, Qt works!");
 return 0;
}

To compile this code, go to the previously created directory with the Visual Studio prompt command. Do:

$> qmake -project

This analyzes the current directory and sub-directories and generates a .pro file (Qt project file) which has the same name than the current directory. Then, do:

$> qmake

This generates a Makefile. Finally, do:

$> nmake 

If the compilation succeeded, you should be able to run the application in the Debug directory

Delete temporary files

All files and directories created in C:\tmp can be deleted.

Compile ClientServer module

Generate Microsoft Visual C++ projects with CMake. The compilation can be done within Visual C++, like the rest of COOLFluiD. Compiling "app_client" and "app_server" projects will build everything that is needed.

Do a full compilation of Qt

To do a full compilation of Qt, follow the previously described steps, but use this configure command:

$> configure -prefix "C:\Qt\4.5.2" -platform win32-msvc2008 -opensource

to configure and do not edit the "projects.pro" file.