Building Lua, IM, CD and IUP in Windows

This is a guide to build all the Lua, IM, CD and IUP libraries in Windows. 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.

System Configuration

The Tecmake configuration files are for the GNU make tool. So first the GNU make must be installed, and it must be in the PATH before other makes. MingW, MingW-w64 , Cygwin and Win-builds distributions have the GNU make binaries ready for download.

The mkdir and rm utilities are also necessary. 

To build the dependencies file you will need: which, sed and g++. If you don't need the dependencies or some other options just ignore them. You can set NO_DEPEND=Yes to disable the dependencies build.

And some features will work best if bash is installed.

Cygwin and MingW* (with MSYS) have all these tools.

When installing Cygwin un-select all pre-selected items. This is easier to do in "Partial" mode view. Then select only "make", it will automatically select other packages that "make" depends on. And select the mkdir, rm, which, sed and g++ packages. Change PATH in "Control Panel/System/Advanced/Environment Variables" and add "c:\cygwin\bin;".

When installing MingW select: C Compiler, C++ Compiler, MSYS Basic System, and MinGW Developer Toolkit. Change PATH in "Control Panel/System/Advanced/Environment Variables" and add "C:\mingw4\msys\1.0\bin;C:\mingw4\bin;".

Notice that in alternative distributions of MingW, like TDM-gcc or Mingw-w64, make is named "mingw32-make" and MSYS is available as a separate package.

As an alternative, Win-Bash contains a "Shell-Complete" distribution and can also be used. It contains all the tools and bash. It does not include a compiler.

Finally install the compiler of your choice, among the following supported compilers:

Tecmake Configuration

Since the compilers in Windows are not in the path, you must set a few environment variables to configure their location. For example:

VC10=c:/progra~2/micros~1/vc               (C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC)
VC10SDK=c:/progra~1/micros~1/Windows\v7.1  (C:\Program Files\Microsoft SDKs\Windows\v7.1)
                                  (if you only installed the Windows SDK with its own compiler set, 
                                   then set both variables to the same location)
                                  (VC9,VC9SDK,VC8 and PLATSDK can also be set)
MINGW4=c:/mingw
GCC4=c:/cygwin
OWC1=d:/lng/owc1
BC6=d:/lng/bc6

Noticed that the path used can not have spaces because of the GNU make internal processing. So you should install or copy the compiler files to a path with no spaces, or you can use the short path name instead as in the example above. To obtain the short path name you can use the "shortpath.exe" Tecmake utility or use the CMD command “dir /X”.

If you installed the Visual Studio compiler set, then to use it in the command line run the "Visual Studio Command Prompt" item in the "Microsoft Visual Studio 2010\Visual Studio Tools" start menu.

In Windows, there are several compilers that build for the same platform. So when using the Makefiles included in the distributions of those libraries you must first specify which compiler you want to use. To do that set the TEC_UNAME environment variable. This variable will also define if you are going to build static or dynamic (DLL) libraries, and if building 32 or 64 bits binaries. For example:

TEC_UNAME=vc10      (Visual C++ 10, static library, 32bits)
TEC_UNAME=dll10     (Visual C++ 10, dynamic library, 32bits) 
TEC_UNAME=vc10_64   (Visual C++ 10, static library, 64bits)
TEC_UNAME=dll10_64  (Visual C++ 10, dynamic library, 64bits) 
TEC_UNAME=mingw4    (MingW gcc 4, static library, 32bits)
TEC_UNAME=dllw4     (MingW gcc 4, dynamic library, 32bits)
TEC_UNAME=gcc4      (Cygwin Win32 gcc 4, static library, 32bits)
TEC_UNAME=cygw17    (Cygwin Posix gcc 4, both static and dynamic libraries, 32bits)
TEC_UNAME=owc1      (Open Watcom C++ 1, static library, 32bits)
TEC_UNAME=bc6       (Embarcadero C++ 6, static library, 32bits) 

Here is an example for MingW:

Download MingW installation tool:
  http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/
Install MingW:
  Select C and C++ Compiles, MSYS Basic System, and MinGW Developer Toolkit.
Configure Environment (Minimum):
  set PATH=C:\mingw4\msys\1.0\bin;C:\mingw4\bin;%PATH%
  set MINGW4=c:/mingw4
  set TEC_UNAME=mingw4
Start Building:
  make

Here is an example for Visual C++:

Download Visual C++ Express edition:
  http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-for-windows-desktop
Install Visual C++ and the Windows SDK (also called Platform SDK)
Download Cygwin:
  http://www.cygwin.com/
Install Cygwin:
  Unselect all option, and select only "make"  
Configure Environment (Minimum):
  set PATH=C:\cygwin\bin;%PATH%
  set VC9=C:/PROGRA~1/MICROS~1.0/VC
  set VC9SDK=C:/PROGRA~1/MICROS~2/Windows/v6.0A 
Run the "CMD Shell" or "Build Environment" item in the Start Menu. 
  or manually run the vcvars32.bat or vcvars64.bat script
  just once, before building any of the targets.

If not using the vcvars*.bat configuration scripts, then you must also set PATH:

REM The first two are just auxiliary variables.
set VS9=C:\Program Files (x86)\Microsoft Visual Studio 9.0
set VS9SDK=C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin
set PATH=%VS9%\Common7\IDE;%VS9%\VC\BIN;%VS9%\Common7\Tools;%VS9%\Common7\Tools\bin;%VS9%\VC\VCPackages;%VS9SDK%\bin;%PATH%

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 - http://sourceforge.net/projects/luabinaries/files/
IM - http://sourceforge.net/projects/imtoolkit/files/
CD - http://sourceforge.net/projects/canvasdraw/files/
IUP - http://sourceforge.net/projects/iup/files/

Unpacking

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]

unzip lua-5.3.3_Sources.zip    [optional, see note below]
unzip zlib-1.2.8_Sources.zip
unzip freetype-2.6.3_Sources.zip
unzip ftgl-2.1.4_Sources.zip
unzip im-3.11_Sources.zip
unzip cd-5.10_Sources.zip
unzip iup-3.19_Sources.zip

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

/xxxx/
      cd/
      freetype/  (included in CD)
      ftgl/      (included in CD)
      im/
      iup/
      lua53/      
      zlib/      (included in IM)

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

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.

Building

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
make
cd ../..

// repeat for zlib, Freetype, FTGL, IM and CD

cd iup
make
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.

Pre-compiled Binaries

Instead of building from sources you can try to use the pre-compiled binaries. Usually they were build in the latest Windows versions for 32 and 64 bits. The packages are located in the "Windows Libraries" directory under the Files section in Source Forge, with "xxx-X.X_Win32_xx_lib.tar.gz" and "xxx-X.X_Win64_xx_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_Win32_vc10_lib.tar.gz
cd ..

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

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

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

Usage

For makefiles use:

1) "-I/xxxx/iup/include" and so on, to find include files when compiling
2) "-L/xxxx/iup/lib/vc10" and so on, to find library files when linking
3) "-liup" and so on, to specify the library files when linking 

For IDEs the configuration involves the same 3 steps above, but each IDE has a different dialog. The IUP toolkit has a Guide for some IDEs:

Borland C++ BuilderX - http://www.tecgraf.puc-rio.br/iup/en/ide_guide/cppbx.html
Code Blocks - http://www.tecgraf.puc-rio.br/iup/en/ide_guide/codeblocks.html
Dev-C++ - http://www.tecgraf.puc-rio.br/iup/en/ide_guide/dev-cpp.html
Eclipse for C++ - http://www.tecgraf.puc-rio.br/iup/en/ide_guide/eclipse.html
Microsoft Visual C++ (Visual Studio 2003) - http://www.tecgraf.puc-rio.br/iup/en/ide_guide/msvc.html
Microsoft Visual C++ (Visual Studio 2005) - http://www.tecgraf.puc-rio.br/iup/en/ide_guide/msvc8.html
Open Watcom - http://www.tecgraf.puc-rio.br/iup/en/ide_guide/owc.html