Ana səhifə

Instructions for Linux 1- install fltk. The installation is very straightforward

Yüklə 29 Kb.
ölçüsü29 Kb.
FLTK Installation Instructions for Linux

1- Install FLTK.

The installation is very straightforward.

Download the source code (bz2 or gz) from and save it to your home folder.
I would recommend version 1.1.7 to avoid any incompatibility.

The '#' sign at the beginning of each command is just to indicate that it is a command. Do not enter the '#' sign on your Linux or Unix command line; only enter what follows the '#' sign. All commands to be typed at the Linux or Unix prompt will be highlighted in green to avoid confusion.

Enter your home folder
# cd ~

Untar the FLTK source

# tar xvfj fltk-1.1.7-source.tar.bz2
or if you have downloaded the tar.gz version, use this command instead
#tar xvfz fltk-1.1.7-source.tar.gz

Change to the FLTK folder

# cd fltk-1.1.7

Configure the makefile, compile the source code and install (you must be root to install, or else use sudo)

# ./configure
# make && make install

2- Install the glue code from the course website.

The glue code is code written to make it easy for us students to use FLTK. Without it you will not be able to compile any of the code in the book, since that code does not use the FLTK implementation directly.

Point your browser to, and scroll down to the code section.
Create a folder named 'project' in your home folder

# cd ~
# mkdir project

# cd project

Download the files below and save them inside the project folder.


Create the object files Graph.o, Window.o and GUI.o

# g++ -c GUI.cpp Graph.cpp Window.cpp

Congratulations, you have just completed the installation of FLTK for this class!

3- How to use the glue code to compile an example from class.

To be able to compile a graphics program using the glue files you need to put the code in the same directory where we previously downloaded, the 'project' folder. But this can be very messy.

A better way is to create a subfolder inside the 'project' folder and save code that we write there, changing the include directives to something like:

#include "../Window.h"

#include "../Graph.h"
#include "../GUI.h"
#include "../std_lib_facilities.h"

This insures that g++ finds the necessary glue code. Here is an example:

Create a subfolder 'sample' in the 'project' folder'
# mkdir sample

Download  sample_main2.cpp from in the code section and save it inside the sample directory. Change the include directives as noted above. Now compile it with the command

# g++ -o sample_main2 GUI.o Window.o Graph.o sample/sample_main2.cpp -lfltk -lXft
Note: Always put the -lfltk -lXft at the end along with any other libraries you might need (-lm for math, etc.); otherwise, you will end up with a lot of unknown symbol error messages.

Run it.
# ./sample_main2

Note for people installing FLTK using a package manager such 'emerge' under gentoo

If you decide instead to install FLTK using a package manager such as 'emerge' under gentoo Linux, make sure to do the following for g++ to find the include files:

# ln -snf /usr/include/fltk-1.1/FL Fl
# ln -snf /usr/include/fltk-1.1/FL FL

For Debian, Redhat or any other Linux distribution, I do not know where FLTK will be installed using their package manager. In any case you can always find out where the include files were installed and make a soft link to it inside your g++ include folder.

To compile a program from class the command will now be

# g++ -o sample_main2 GUI.o Window.o Graph.o sample/sample_main2.cpp -lfltk -lXft -L/usr/lib/fltk-1.1

Notice that we have added -L/usr/lib/fltk-1.1 to tell g++ where the FLTK library was installed.
And again this is for gentoo users. If you use another distribution, just find where the FLTK library is and change the –L to that.

If you find any errors in these instructions or have questions please send me an email at

Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur © 2016
rəhbərliyinə müraciət