Building Lua, IM, CD and IUP in Linux

This is a guide to build all the Lua, IM, CD and IUP libraries in Linux. Notice that you may not use all the libraries, although this guide will show you how to build all of them. You may then choose to build specific libraries.

The Linux used as reference is the Ubuntu distribution.

System Configuration

To build the libraries you will have to download the development version of some packages installed on your system. Although the run time version of some of these packages are already installed, the development versions are usually not. The packages described here are for Ubuntu, but you will be able to identify them for other systems as well.

To build Lua you will need:


To build IM you will need:


To build CD you will need:

libgl1-mesa-dev and libglu1-mesa-dev (for the ftgl library used by CD_GL)
libgtk2.0-dev (for the GDK driver)
libgtk-3-dev (for the GTK driver)
  libx11-dev (for the X11 driver, OPTIONAL)
  libxpm-dev (")
  libxmu-dev (") 
  libxft-dev (for the XRender driver, OPTIONAL)

To build IUP you will need:

libgtk2.0-dev (for the GTK driver) 
libgtk-3-dev (for the GTK driver) 
  libmotif-dev and x11proto-print-dev (for the Motif driver, OPTIONAL)
libgl1-mesa-dev and libglu1-mesa-dev (for the IupGLCanvas)
libwebkit-dev or libwebkitgtk-dev (for the IupWebBrowser using GTK 2)
libwebkitgtk-3.0-dev (for the IupWebBrowser using GTK 3)

To install them you can use the Synaptic Package Manager and select the packages, or can use the command line and type:

sudo apt-get install package_name

Source Download

Download the "xxx-X.X_Sources.tar.gz" package from the "Docs and Sources" directory for the version you want to build. Here are links for the Files section in Source Forge:

Lua -
IM -
CD -


To extract the files use the tar command at a common directory, for example:

mkdir -p xxxx
cd xxxx

[copy the downloaded files, to the xxxx directory]

tar -xpvzf lua-5.3.3_Sources.tar.gz    [optional, see note below]
tar -xpvzf ftgl-2.1.4_Sources.tar.gz
tar -xpvzf im-3.11_Sources.tar.gz
tar -xpvzf cd-5.10_Sources.tar.gz
tar -xpvzf iup-3.19_Sources.tar.gz

If you are going to build all the libraries, the makefiles and projects expect the following directory tree:

      freetype/  (included in CD, but not used in Linux, install the freetype-dev package)
      ftgl/      (included in CD)
      lua53/     [optional, see note below]
      zlib/      (included in IM, but not used in Linux, install the zlib-dev package)

If you unpack all the source packages in the same directory, that structure will be automatically created.

If you want to use some of these libraries that are installed on the system (see Installation section below) you will have to define some environment variables before building them. For example:

export IM_INC=/usr/include/im
export IM_LIB=/usr/lib           [not necessary, already included by gcc]

export CD_INC=/usr/include/cd
export CD_LIB=/usr/lib           [not necessary, already included by gcc]

export IUP_INC=/usr/include/iup
export IUP_LIB=/usr/lib          [not necessary, already included by gcc]


Although we use Lua from LuaBinaries, any Lua installation can also be used. In Ubuntu, the Lua run time package is:


And the Lua development package is:


To use them, instead of using the directory "/xxxx/lua5.1" described above, you will have to define some environment variables before building IM, CD and IUP:

export LUA_SUFFIX=
export LUA_INC=/usr/include/lua5.1

By default the Makefiles and Tecmake files will build for Lua 5.1. To build for other Lua versions define USE_LUA_VERSION=52 or USE_LUA_VERSION=53 in the environment.


As a general rule (excluding system dependencies): IUP depends on CD and IM, and CD depends on IM. So start by build IM, then CD, then IUP.

To start building go the the "src" directory and type "make". In IUP there are many "srcxxx" folders, so go to the up directory "iup" and type "make" that all the sub folders will be built. For example:

cd lua53/src
cd ../..

// repeat for FTGL, IM and CD

cd iup
cd ..

TIP: Instead of building all the libraries, try building only the libraries you are going to use. The provided makefiles will build all the libraries, but take a look inside them and you will figure out how to build just one library.

TIP: If GTK headers or libraries are not being found, even when the libgtk2.0-dev package is installed, then their installation folder is not where our Makefiles expect. Build the GTK/GDK dependent libraries using "make USE_PKGCONFIG=Yes".

Pre-compiled Binaries

Instead of building from sources you can try to use the pre-compiled binaries. Usually they were build in the latest Ubuntu versions for 32 and 64 bits. The packages are located in the "Linux Libraries" directory under the Files section in Source Forge, with "xxx-X.X_Linux26g4_lib.tar.gz" and "xxx-X.X_Linux26g4_64_lib.tar.gz" names.

Do not extract different pre-compiled binaries in the same directory, create a subdirectory for each one, for example:

mkdir lua53
cd lua53
tar -xpvzf ../lua-5.3.3_Linux26g4_lib.tar.gz    (if not using Lua from the system)
cd ..

mkdir im
cd im
tar -xpvzf ../im-3.6.2_Linux26g4_lib.tar.gz
cd ..

mkdir cd
cd cd
tar -xpvzf ../cd-5.4_Linux26g4_lib.tar.gz
cd ..

mkdir iup
cd iup
tar -xpvzf ../iup-3.2_Linux26g4_lib.tar.gz
cd ..

For the installation instructions below, remove the "lib/Linux26g4" from the following examples if you are using the pre-compiled binaries.

Installation (System Directory)

After building you can copy the libraries files to the system directory. If you are inside the main directory, to install the dynamic libraries you can type, for example:

sudo cp -f im/lib/Linux26g4/*.so /usr/lib               [script version: install ]
sudo cp -f cd/lib/Linux26g4/*.so /usr/lib
sudo cp -f iup/lib/Linux26g4/*.so /usr/lib

To install the development files, then do:

sudo mkdir -p /usr/include/im                           [script version: install_dev ]
sudo cp -fR im/include/*.h /usr/include/im
sudo cp -f im/lib/Linux26g4/*.a /usr/lib

sudo mkdir -p /usr/include/cd
sudo cp -f cd/include/*.h /usr/include/cd
sudo cp -f cd/lib/Linux26g4/*.a /usr/lib

sudo mkdir -p /usr/include/iup
sudo cp -f iup/include/*.h /usr/include/iup             
sudo cp -f iup/lib/Linux26g4/*.a /usr/lib                               

Then in your makefile use -Iim -Icd -Iiup for includes. There is no need to specify the libraries directory with -L. Development files are only necessary if you are going to compile an application or library in C/C++ that uses there libraries. To just run Lua scripts they are not necessary.

Installation (Build Directory) [Alternative]

If you don't want to copy the dynamic libraries to your system directory, you can use them from build directory. You will need to add the dynamic libraries folders to the LD_LIBRARY_PATH (DYLD_LIBRARY_PATH in MacOSX), for example:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/xxxx/im/lib/Linux26g4:/xxxx/cd/lib/Linux26g4:/xxxx/iup/lib/Linux26g4
or for the current folder

And in your makefile will will also need to specify those paths when linking using -L/xxxx/iup/lib/Linux26g4, and for compiling use -I/xxxx/iup/include.

Installation (Lua Modules)

Lua modules in Ubuntu are installed in the "/usr/lib/lua/5.1" directory. So to be able to use the Lua "require" with IUP, CD and IM you must create symbolic links inside that directory.

sudo mkdir -p /usr/lib/lua/5.1                          [script version: config_lua_module ]
cd /usr/lib/lua/5.1  
sudo ln -fs /usr/lib/
sudo ln -fs /usr/lib/

Using those links you do not need any extra configuration.

Installation (Lua Modules) [Alternative]

If you use the alternative installation directory, and you also do NOT use the LuaBinaries installation, then you must set the LUA_CPATH environment variable:

export LUA_CPATH=./\?.so\;./lib\?.so\;./lib\?\;