![]() |
![]() |
![]() |
![]() |
![]() |
What
do I need ?
A Linux/Unix machine (a motherboard, an hard disk, a screen,a keyboard and a processor could be interesting).
Note that I'll never support Windows systems.A C++ compiler. You can take for example the GNU compiler, but other compilers should work. GNU make. (a version posterior to 1997) (If you don't have it, it's fast and easy to install) (Note that other make program will probably not work)
Download
the library an unpack archives
The library is divided into several parts: the kernel, which is the core of the library (it should be stable...) and some packages developed by any user. Just go in the download section to take what you need (at least the kernel).Unpack the kernel: a Torch directory should appear, with some directories inside (the sources of the kernel will be in the kernel directory...).
If you have downloaded packages, unpack them in the Torch directory.
The library needs a file named "Makefile_options_<os>" to compile, where <os> is the name of you operating system, given by the command "uname -s". This file must be in the Torch directory. There are some examples of this file in the config directory.Therefore, check the name of your OS with "uname -s" and copy an example of Makefile_options_* from the directory config to the root of Torch. For example, if you have a SunOs system, and you're using the CC workshop compiler, copy the file Torch/config/Makefile_options_CC in the file Torch/Makefile_options_SunOs.
After you've copied this file, edit it. It should look like the following (if you are using the GNU compiler file example).
(Red comments are not in the file)# Packages you want to use
# For example if you have dowloaded addons and speech, put "PACKAGES = addons speech"
# Don't include packages which contain main programs (such as "examples")
# Don't include "kernel"
PACKAGES =# Magik key if you have several makefile
# for the same platform
# (It's useful if you're using two different compilers: a different file
# for dependencies will be generated for each MAGIC_KEY)
MAGIK_KEY =# Compiler, linker and archiver
CC = g++
LD = g++
AR = ar -rus![]()
# Command for creating dependencies
# Check the documentation of your compiler if you don't know that...
DEP = g++ -MM![]()
# Your librairies
# (for example "-lm", but not needed on most systems...)
MYLIBS =# optimize mode
# Comment one of these lines... OPT is for optimized code,
# and DBG for debug code (if you plan to use a debugger)
DEBUG = OPT
# debug mode
#DEBUG = DBG# Comment one of these lines... if you take DOUBLE (and comment FLOAT)
# the "real" variables will be "double". Otherwise "float".
# double version
#FLOATING = DOUBLE
# floating version
FLOATING = FLOAT# Check here the flags for your compiler.
# -DUSEDOUBLE is used to define USEDOUBLE in the code (for CFLAGS_*_DOUBLE flags).
# Debug double mode
CFLAGS_DBG_DOUBLE = -g -Wall -pedantic-errors -DUSEDOUBLE# Debug float mode
CFLAGS_DBG_FLOAT = -g -Wall -pedantic-errors# Optimized double mode
CFLAGS_OPT_DOUBLE = -Wall -pedantic-errors -O9 -ffast-math -mcpu=i686 -march=i686 -malign-double -DUSEDOUBLE# Optimized float mode
CFLAGS_OPT_FLOAT = -Wall -pedantic-errors -O9 -ffast-math -mcpu=i686 -march=i686 -malign-double# Don't care about the end of the file
[...]
That's easy. Just do "make depend" and then "make". If you want you can use the option "-j" of the GNU make file (for example "make -j 4"): it could improve the speed of the compilation, especially on multiprocessor systems. If everything went ok, several directories should have been created: objs in which you'll find all the object files, and lib in which you'll find the library.You should'nt have any warning during the compilation... otherwise, send me an email, if it's related to the code of the library.
In fact, the following commands are available for make:
- make : compile the library
- make clean : remove the dependency files, the objects and the library for the current system.
- make distclean : remove the dependency files, the objects and the library for all the systems.
- make depend : create the dependency files.
Create a directory in Torch. Go in this directory, edit your program. Then copy in the directory the Makefile that you'll found in Torch/config. After that, if the name of you program is foo.cc, just do "make foo" (without the .cc extension!). A subdirectory will appear (with a name corresponding to your compilation flags and your OS) with the program "foo"...