GNU C++ on Linux
ClanLib does not provide Linux binaries, and if your
distribution does, they may well be out of date (e.g. Ubuntu
11.10's libclanlib-dev is ClanLib 1.0). 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. If you have a slow internet connection and only
intend to use some ClanLib modules, you may want to look at
the Module-by-module dependency
list instead.
Debian & Ubuntu
sudo apt-get install make automake autoconf autotools-dev m4 libtool libc6-dev linux-libc-dev g++ \
zlib1g zlib1g-dev libpng12-0 libpng12-dev libjpeg62-dev libfreetype6 libfreetype6-dev \
x11proto-xf86vidmode-dev libxxf86vm-dev libfontconfig1-dev libxi-dev libgl1-mesa-dev \
libice-dev libsm-dev libx11-dev libxau-dev libxdmcp-dev libxext-dev libxt-dev mesa-common-dev \
x11proto-core-dev x11proto-input-dev x11proto-kb-dev x11proto-xext-dev xtrans-dev libasound2-dev \
libmikmod2 libmikmod2-dev libvorbis0a libvorbis-dev libogg-dev libpcre3 libpcre3-dev libsqlite3-dev libxrender-dev doxygen
Fedora
sudo yum install make automake autoconf autotools-dev m4 libtool libc6-dev linux-libc-dev g++ \
zlib1g zlib1g-dev libpng12-0 libpng12-dev libjpeg62-dev libfreetype6 libfreetype6-dev \
x11proto-xf86vidmode-dev libxxf86vm-dev libfontconfig1-dev libxi-dev libgl1-mesa-dev \
libice-dev libsm-dev libx11-dev libxau-dev libxdmcp-dev libxext-dev libxt-dev mesa-common-dev \
x11proto-core-dev x11proto-input-dev x11proto-kb-dev x11proto-xext-dev xtrans-dev libasound2-dev \
libmikmod2 libmikmod2-dev libvorbis0a libvorbis-dev libogg-dev libpcre3 libpcre3-dev libsqlite3-dev libxrender-dev doxygen pcre-devel libmikmod-devel
CentOS 5/6
sudo yum install make automake autoconf m4 gcc-c++ zlib zlib-devel mesa-libGL* doxygen \
libvorbis libvorbis-devel libogg-devel sqlite*
Some 3D examples require assimp. See the AssimpLinux page.
Downloading and configuring ClanLib
Download the latest ClanLib release source archive.
Open a terminal prompt and change to the directory you downloaded ClanLib to.
Extract:
tar -xvzf ClanLib-3.0.0.tgz
(Amend the version number as necessary)
Configure (this gives the standard one, see below for other options):
./configure --prefix=/usr
Development version
This version requires autogen before configure:
./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")
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-clanMikMod --enable-clanGL
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
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-3.0 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 3.0.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, and clanVorbis or clanMikmod if you use those formats) or GUI (clanGUI), a different graphics target (clanGL1 or clanSWRender) or a different ClanLib version, amend them accordingly.
Command line
g++ -o mygame mygame.cpp `pkg-config --cflags --libs clanCore-3.0 clanDisplay-3.0 clanGL-3.0 clanSWRender-3.0 clanApp-3.0` -lpthread
Makefile
PACKAGES = clanCore-3.0 clanDisplay-3.0 clanApp-3.0 clanGL-3.0
LIBS = `pkg-config --cflags --libs $(PACKAGES)`
OBJS = mygame.o
all: $(OBJS)
g++ -o mygame -pthread $(OBJS) $(LIBS)
clean:
-rm -rf *.o
-rm mygame
Module-by-module dependency list (Debian/Ubuntu)
Core
automake
autoconf
autotools-dev
m4
libtool
libc6-dev
linux-libc-dev
g++ (g++-4.1 or later and libstdc++6-4.1-dev or later)
zlib1g (Not Required ClanLib 3.0)
zlib1g-dev (Not Required ClanLib 3.0)
Display
libpng12-0
libpng12-dev (Not Required ClanLib 3.0)
libjpeg62-dev (Not Required ClanLib 3.0)
libfreetype6 (unless compiled manually)
libfreetype6-dev (unless compiled manually)
x11proto-xf86vidmode-dev (to enable XF86 VidMode)
libxxf86vm-dev (to enable XF86 VidMode)
libfontconfig1-dev
libxi-dev
libgl1-mesa-dev
libice-dev
libsm-dev
libx11-dev
libxau-dev
libxdmcp-dev
libxext-dev
libxt-dev
mesa-common-dev
x11proto-core-dev
x11proto-input-dev
x11proto-kb-dev
x11proto-xext-dev
xtrans-dev
Sound
libasound2-dev (for alsa)
Documentation
doxygen