Skip to main content

Windows compilation in a nutshell - Compiling Tulip in release and debug mode (part 1)

VII- Compiling Tulip in release and debug mode

When building with CMake, you need to specify several parameters :
  . The source directory : The folder containing Tulip source files.
  . The build directory : CMake keeps objects (.obj) and all other files generated at compilation time in a separate folder in order to keep the source directory clean. This can be any folder on your file system.
  . The installation directory : The folder where files will be installed when running the make install command.
  . The build type : Which can have several values. The most common are Release and Debug. Those values have a direct influence on Tulip generated binaries and software performance.

. The Debug mode provides gcc debugger symbols (-g) and allows debugging with GDB. It also includes a lot of extra verification when using Tulip data structures. When compiling your code in Debug mode, the NDEBUG variable is unset, allowing you to add code that will only be executed in debug mode :
   int f() {
     std ::cout << ‘’This message will always be displayed’’ << std ::endl ;
   #ifndef NDEBUG
     std ::cout << ‘’This message will only be displayed in Debug mode’’ << std ::endl
   #endif /* NDEBUG */
   }

. The Release mode disable extra debug operations and removes debugging symbols. Allowing Tulip to run much faster but removing almost every verification on the data structure.
Note : Unfortunately, there is currently no way to run Tulip in ‘’pure’’ Debug mode. When you select Debug mode in CMake, it will automatically select debug version of its libraries. Causing critical bugs when running Tulip. At the end of this section, you will see how to tweak your CMake configuration in order to generate a debug version of Tulip while using the Qt release libraries.

Run the cmake-gui utility from your start menu :
  1. Input the source code location
  2. Input thebuild folder location.
  3. Click on Configure


Note
: If you are not sure how you can organize your development folders, you can follow this scheme :
Development : The root directory
|__tulip-sources : Contains the source files
|__tulip-build
       |__release : Tulip Release mode folder
       |     |__build : Where you will ask to put the build files
       |     |__install : Where you will ask to install Tulip
       |__debug : Tulip Debug mode folder
              |__build : Where you will ask to put the build files
              |__install : Where you will ask to install Tulip

After you click on Configure, CMake will process for some time then popup an error message : Error in configuration process : project files may be invalid. Click OK. You will be asked to fill several values in the CMake variables below :

 

. In CMAKE_BUILD_TYPE, input Release (we will see how to build In Debug mode at the end of this section)
. In CMAKE_INSTALL_PREFIX, input the folder where you want to install files after running the make install command.
. Leave QT_QMAKE_EXECUTABLE and other values as they are.

Once again, click on Configure.

The Generate button will then become available, click it and wait for the Generating done message below.
You can now close CMake.

Time to build Tulip. Open MSYS (rvxt) from your Start Menu and cd to the directory where you choosed to put build files.

Note : MSYS is a UNIX shell environment emulator. You can then use any of the usual shell commands (like ls, cat, etc) or even execute bash scripts. File path are also similar to a UNIX system. So the Windows C:\Windows will become /c/Windows in MSYS.

If you run the ls command, you will see several files generated by CMake. Along with a Makelist file. You can then type make to start compiling as you would normally do on UNIX.

You will notice that compilation output format is slightly different than with a classical Makefile or with autotools. CMake adds extra output to provide information about advancement in compilation stage.

UNIX users will notice that compilation on Windows is pretty much slower than UNIX. It seems to come from the disk access gcc has to do to read source files and write objects.
Tulip compilation can be rather slow, depending of the number of processors you have, so time to get some coffee and come back when it’s all done
When your finished, run the usual make install command.

Tulip binaries, include files and libraries will be installed in the directory you specified at CMake configuration stage. You can now open this folder, go into the bin directory and run tulip.exe

Next step: Compiling Tulip in release and debug mode (part 2)
Previous step: Downloading Tulip sources