User:Daggerstab/Building Stellarium on Windows with Qt Creator

From Stellarium Wiki
Jump to: navigation, search


Install the Qt SDK

Stellarium is based on the Qt framework, so you need to install it. Before, the Qt libraries and Qt Creator were distributed separately, but then Nokia integrated all Qt components in a SDK. So you can download a small installer, and select and download only the components you are going to use.

  • Qt downloads page:
  • The "online installer" for Windows is only 15 MB and allows you to pick which components to download and install
  • You need Qt Creator and the Qt Desktop libraries (open source, with MinGW), so in the component selection screen:
    • Under "Development Tools":
      • Under "Desktop Qt", make sure that the latest version of Qt is checked (as of November 2011, that is 4.7.4). Under the version number, select only "Desktop Qt 4.7.4 - MinGW"
      • Make sure "Qt Designer" is selected
      • You probably don't need anything else under "Development Tools", so feel free to uncheck the rest.
    • Under "Miscellaneous", make sure that "MinGW 4.4" is checked. You don't need the source code. You may need the Qt Examples only if you are a programmer and you want to contribute to Stellarium - they will be useful to understand Qt.
    • You need "Documentation" only if you are a programmer who wishes to contribute to Stellarium.
    • You don't need "APIs" and "Experimental".

Even if you miss anything at this point, you can install it later with the "Maintain Qt SDK" application (it can be found in the Start menu after the installation is complete).

Remember where you install the Qt SDK, because you'll need it later.

Install some GnuWin libraries

Stellarium needs gettext, libiconv and zlib. You can get them form the GnuWin project:

For all of them, download the "Complete package, except sources" executable installer. Run the installers and let them install the libraries to the directory they want. It should be something like C:\Program Files\GnuWin32

Setting environmental variables

You need to add a few paths to your PATH environmental variable. On Windows, you can modify it with a configuration window: right click on your "My computer" and select "Properties". It's somewhere there. :)

TIP: The environmental variables window allows you to modify and define env-variables for the current user and for the system. There should be already a "Path" variable defined for the system, but not for the user. Instead of modifying the system PATH, it is more convenient to define a user PATH (just click on the "New..." button and fill in the boxes).

If you have let the Qt SDK install itself in its default location, the path to the Qt libraries should be something like C:\QtSDK\Desktop\Qt\4.7.4\mingw You need to add three subdirectories to the PATH variable:


You also need to add the GnuWin libraries:

C:\Program Files\GnuWin32\bin
C:\Program Files\GnuWin32\lib
C:\Program Files\GnuWin32\include

All elements of the list should be separated with a semicolon (;). So the end result should look something like this: C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin;C:\QtSDK\Desktop\Qt\4.7.4\mingw\lib;C:\QtSDK\Desktop\Qt\4.7.4\mingw\include;C:\Program Files\GnuWin32\bin;C:\Program Files\GnuWin32\lib;C:\Program Files\GnuWin32\include

Warning: Don't just blindly copy the paths. Make sure that these directories exist and that the Qt version number is the same as yours.

Install CMake

CMake download page:

And interesting bug: As of 9 November 2011, if you use CMake 2.8.*, on Windows 7, Qt Creator won't show you Stellarium's source file tree in the "Projects" panel. Download and use CMake 2.6.4 (from the same website). If you have any idea why this is happening, contact us in the Stellarium developers mailing list or the Feedback forums.

During the installation, make sure to tell the installer that CMake should be added to the system PATH (for all users). This will save you editing it manually. :)

Get Stellarium's code

See the Bazaar checkout instructions

Opening Stellarium with Qt Creator

Open Qt Creator.

Open "File" -> "Open File or Project..." (or just press Ctrl+O).

Find the folder where you have put Stellarium's files. Open the topmost CMakeLists.txt file - the one that is at the same level as the README file and the /src and /data directories.

A "CMake Wizard" window will open. It is small and inconvenient to use. You can resize it to a larger size.

  • In the "Build Location" step, there will be a default path already in the location field. Ignore it. Instead:
    • Select your base Stellarium location, the same directory where the CMakeLists.txt file was. For example, D:\stellarium\trunk
    • Then, add \builds\msys. The whole path should look like something like this:D:\stellarium\trunk\builds\msys
    • The point is that this will allow you to run Stellarium directly from inside Qt Creator without having to copy files or to create an installer and install Stellarium.
  • In the "Run CMake step", there is an "Arguments" field where you can set CMake command-line arguments.
    • You can use it to set Stellarium's pseudo-installation directory. This is necessary only if you want to use a trick useful to translators (described below) or to create an executable installer. Just type in -DCMAKE_INSTALL_PREFIX=c:\stellarium-temp\, where c:\stellarium-temp\ is the path to the pseudo-installation directory. (It is not necessary to exist, CMake will create it.)
    • When you are done with the arguments, click on the "Run CMake" button. CMake will start and its log will be displayed in the box below. If everything is OK, the last lines will be something like: "Configuring done. Generating done. Build files have been written to <your build directory>" The "Finish" button will be enabled. Click it to close the wizard.

After you close the wizard, Qt Creator should open the project.

Tip: You can always run again CMake by choosing "Run CMake" from the "Build" menu.

Building Stellarium

Running Stellarium

Creating an installer

Inno Setup and the project file

Stellarium uses Inno Setup to create its Windows installers, so you need to download and install Inno Setup first.

The Inno Setup project file that contains the rules for creating the installer is called stellarium.iss. It is generated from the template stellarium.iss.cmake when you run CMake, so:

  • To have stellarium.iss, you need to have run CMake and/or built Stellarium at least once.
  • If you run CMake (or build Stellarium?) after you've made changes to stellarium.iss, they will be overwritten, so be careful - always keep in mind what changes do you want to make and why, and in which file do you need to make them.

Building in "install" configuration

Running Inno Setup

After Stellarium has been built in the "install configuration" (and files have been copied to the temporary installation directory), open the stellarium.iss file with Inno Setup (just double-click it). You can make some final changes before running the script.

By default, the new installer will be created in the /installers sub-directory in the main directory of your Stellarium working tree. Bazaar is set to ignore it, so you can't accidentally commit a setup file to the repository.

Using translations

Personal tools
in this wiki
other languages