Version 4, last updated by poliklosio at June 22, 2010 11:31 UTC

The PKgui library has four compile options that allow:

  • Speeding up compilation (define PKGUI_BUILD_COLLECTIVELY macro).
  • Removing dependancy on SDL_ttf library (define PKGUI_NO_SDL_TTF_DEPENDANCY macro).
  • Removing dependancy on SDL_image library (define PKGUI_NO_SDL_IMAGE_DEPENDANCY macro).
  • Including unit testing code (define PK_DEBUG macro).

What I mean by writing "define macro" is to add a compilation option, which defines the macro for you. In particular, do NOT modify the header files to add the macros. In G++ the option is -DMACRO_NAME, for example, to define PKGUI_BUILD_COLLECTIVELY, write -DPKGUI_BUILD_COLLECTIVELY. In Eclipse go to Project/Properties/C/C++ Build/Settings/Tool Settings/GCC C++ Compiler/Preprocessor and add one entry in the Defined Symbols (-D) window. In Code::Blocks go to Project/Build Options, choose Compiler settings tab and, inside it, click #defines tab and add macro there.

The library should work with any combination of the above macros. Recommended combination for an ordinary beginner is to define PKGUI_BUILD_COLLECTIVELY, PKGUI_NO_SDL_TTF_DEPENDANCY and PKGUI_NO_SDL_IMAGE_DEPENDANCY. 

This is exactly what happens if the macros are defined: 

  •  PKGUI_BUILD_COLLECTIVELY causes including cpp files into collective cpp files, and hiding code from the included cpp files when they are compiled individually. This causes the individual cpp files to be compiled instantaneously (as nothing is compiled in them). The collective cpp files now contain contents of many files, which prevents the compiler from opening and including .h files multiple times. Thus, compilation of the whole library is sped up about 4 times (takes less than 1.5 minute on my machine).
  • PKGUI_NO_SDL_TTF_DEPENDANCY excludes useful code from PKttf_font.h and PKttf_font.cpp files. Those are the only files which include <SDL/SDL_ttf.h> so if the macro is defined, there is no need for having SDL_ttf installed or linking with it. SDL_ttf provides limited support for True Type fonts (fonts saved in *.ttf files). Note that there is bitmap font support in PKgui (look at PKbitmap_font class), so don't strain yourself to install SDL_ttf, if you don't have to.
  • PKGUI_NO_SDL_IMAGE_DEPENDANCY excludes the PKsdl_image_loader class from the PKsdl_image_loader.h file. This is the only file which includes <SDL/SDL_image.h> so if the macro is defined, there is no need for having SDL_image installed or linking with it. SDL_image library provides limited support for loading (NOT for saving) image files of various formats (like .PNG, .TGA and so on), while SDL only supports 24bit .BMP format.
  • PK_DEBUG causes inclusion of automatic testing code: the PKtester, PKtest_manager and many classes named "test_*". Include the automatic testing code if you want to modify the PKgui code. Run the tests as shown in the main.cpp file of the example application. Running the tests catches limited number of bugs caused by changes.