Manual: Installation

From KODE Wiki
Jump to: navigation, search
KODEManual.png
This article is part
of the KODE Manual
Chapters
Introduction
Install and Use
Concepts
Quick Tutorial
API Reference
World
Body
Joints
Geoms
Spaces
Vector3

Getting the Source Code[edit]

KODE's source code is hosted in Bitbucket: http://bitbucket.org/danielko/kode

Currently there are no official releases, so the code can be obtained by cloning the repository:

hg clone http://bitbucket.org/danielko/kode

Alternatively, you can use Bitbucket's web interface to download a snapshot of the repository.


Dependencies[edit]

  • pkg-config : it's the ubiquitous tool for finding installed libraries on a unix-like system. You might need to set the PKG_CONFIG_PATH environment variable to also include custom installation paths; that is, if by default you install into /usr/local, add this line to your .bashrc:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
This will ensure that manually-installed libraries (that go to /usr/local by default) can be found by pkg-config.
  • Eigen 3 (Optional) : Instead of re-inventing the wheel, KODE performs the heavy numerical work through Eigen, which has platform-specific optimizations; there's a fall-back implementation using plain arrays, but it doesn't try to be as optimized as Eigen. It's highly recommended to use Eigen 3.
  • Boost (Optional) : Used for unit-testing; although not strictly needed for building KODE, while it is still in heavy development you should always do a make check to run the unit tests.
  • Ogre3D and OIS (Optional): currently there are only samples written in Ogre3D + OIS; install these libraries if you want to run the samples.

Building[edit]

Configuring[edit]

  • Enter the top-level directory and run:
./bootstrap
This will generate the configure script you need to run next.
Note: if you downloaded a release tarball, this step is not necessary.
  • Create a build directory, change to it, and run the configure script from KODE's top-level directory:
mkdir build
cd build
../configure
You might want to pass the --help option to configure to see what arguments can be used. For instance:
../configure --enable-double --prefix=/opt CXXFLAGS="-O3"
would build KODE with double precision using optimization "-O3", and the library would be installed into /opt.

Compiling[edit]

After configuration has finished without issues, run:

make

You'll probably want to use the -jN option to enable parallel compilation, where N is the number of parallel compilation tasks you want.

To run the unit tests that perform some validation on the library, run:

make check

Installing[edit]

Run the command:

sudo make install

If your system doesn't have sudo, use su instead:

su # type in the root's password when prompted
make install
exit

To uninstall KODE, simply use make uninstall instead.


Usage[edit]

To use KODE in your program you need to pass specific CFLAGS and LDFLAGS to your program. This can be done with the help of pkg-config.

Assuming this simple source code in test.cpp:

#include <kode/kode.hpp>

int main()
{
    kode::World world;
}

To compile it from the command-line:

g++ -std=c++11 test.cpp `pkg-config --cflags --libs kode` -o test

In a hand-crafted Makefile it would look like this:

PROGRAM := test
CXX := g++ -std=c++11
CXXFLAGS := -Wall -Wextra -O2 -g $(shell pkg-config --cflags kode)
LDFLAGS := $(shell pkg-config --libs kode)

.PHONY: all clean

all: $(PROGRAM)

clean:
	rm -f *.o $(PROGRAM)

$(PROGRAM) : test.o
	$(CXX) -o [email protected] $^ $(LDFLAGS)

$.o : $.cpp

Note the use of $(shell ...) to invoke pkg-config, instead of backticks.