GNU C++ on Linux - ClanLib SDK
Description: ClanLib is a cross platform C++ toolkit library with focus on games

# GNU C++ on Linux

ClanLib does not provide Linux binaries, and if your distribution does, they may well be out of date. The recommended way to install ClanLib on Linux is hence to compile it from source, as follows.

## Installing Prerequisites

ClanLib requires a C++ compiler and a number of other libraries; how to install these depends on which Linux distribution you are using. The following command downloads and installs everything required to allow use of all parts of ClanLib.

### Debian & Ubuntu

sudo apt-get install make g++ automake libtool libfreetype6-dev libfontconfig1-dev libgl1-mesa-dev libxrender-dev libasound2-dev doxygen libxinerama-dev

Some 3D examples require assimp. See the AssimpLinux page.

## Downloading and configuring ClanLib

Download the latest ClanLib source archive.

Open a terminal prompt and change to the directory you extracted ClanLib to.

./autogen.sh ./configure --prefix=/usr

(If you get: "configure.ac:178: error: possibly undefined macro: AC_MSG_CHECKING", you will need to install the pkg-config package")

Configure (this gives the standard one, see below for other options):

./configure --prefix=/usr

### Alternative configurations

To get a list of available options, run "./configure --help"

Developers may prefer to add --enable-debug to create debug libraries.

You can force enabling of implementations, or disable some - eg.:

./configure --disable-clanSound

By default both shared (.so) and static (.a) libraries are built. Unless you want to make a static release, you will probably only want the shared libraries, so can disable the static ones with:

./configure --disable-static

Doing so will reduce the compile size by a half.

## Compiling and installing

Compile (this will take some long time):

make -j9

Install:

sudo make install

ClanLib should now be ready for use.

Note: On CentOS, you must run this command to be able to compile with ClanLib:

export PKG_CONFIG_PATH=/usr/lib/pkgconfig sudo ldconfig

### Documentation and examples

ClanLib includes API reference documentation within its source files, which can be extracted to HTML using:

./configure --prefix=/usr --enable-docs make html

It will then be found at file:///your ClanLib directory/Documentation/Reference/doxyoutput/html/modules.html

ClanLib also includes a number of examples, which are compiled and run as follows (replace Display/Basic2D with the example category and name):

cd Examples/Display/Basic2D make ./basic2d

On Fedora linux and CentOS, if you get "Package clanApp-4.2 was not found in the pkg-config search path", this command helps fix the problem

export PKG_CONFIG_PATH=/usr/lib/pkgconfig

### Using ClanLib

These examples compile and link a source file named mygame.cpp with the ClanLib 4.2.x modules required for graphics (2D or 3D, using OpenGL 2+) and input. If you use other parts of ClanLib such as networking (clanNetwork), sound (clanSound) or GUI (clanUI), amend them accordingly.

Command line

g++ -o mygame mygame.cpp `pkg-config --cflags --libs clanCore-4.2 clanDisplay-4.2 clanGL-4.2 clanApp-4.2` -lpthread

Makefile

PACKAGES = clanCore-4.2 clanDisplay-4.2 clanApp-4.2 clanGL-4.2 LIBS = `pkg-config --cflags --libs $(PACKAGES)` OBJS = mygame.o all: $(OBJS) g++ -o mygame -pthread $(OBJS) $(LIBS) clean: -rm -rf *.o -rm mygame