[ Return to Articles | Show Comments | Submit Comment ]
Article #598: Beginners guide to building fltk-1.1 or fltk-1.3 with FREE Windows compilers
Created at 11:31 May 16, 2006 by ianmacarthur
Last modified at 09:00 Feb 26, 2014
This note is somewhat dated, but testing recently (February 2014) with fltk-1.3 weekly snapshots and the latest mingw, the process described here still works.
(End of update!)
This is just a short note, intended to introduce newcomers to fltk to some of the ways that fltk can be built, and can in turn be used to build programs, on Microsoft Windows operating systems, using free tools.
Using the free tools outlined here has the added advantage that the build process used is essentially the same as that used at the command line on unix and Mac OSX systems, which aids in the development of portable, cross-platform, code.
Firstly, I'd just like to say: If you already have MSVC-6 or later installed and working, then perhaps this note is not for you. It should suffice to open the provided workspaces in the IDE, select the demo program target (in test/demo) and hit build...
Still with us...?
OK, then I'd like to suggest that the most convenient way to build fltk with freely available tools is to use the gcc-based mingw compiler tools, along with the supporting operating shell.
These instructions assume that's what you are doing, but the instructions as given should work equally well for the (also gcc based) cygwin tools.
So: Lets get some tools...
1 - Obtain the latest mingw toolchain from http://www.mingw.org. There are details on their website, but you will need to obtain several files, particularly the compiler itself (gcc-core and gcc-g++), the tools for manipulating binary files that the compiler uses (binutils) and the files for the win32 API (w32api), and finally the utilities kit (mingw-utils). Install these on your machine as directed.
2 - Obtain a build environment: these tools work from the command line. they *will* work perfectly well from a "DOS box", but they are more convenient to use from their own "command shell." Download and install the Msys shell, and the developers toolkit (Msys-DTK). When you install these, they will ask you where your mingw is installed. Install Msys *before* you install the DTK.
3 - There are a number of other things that might be useful: notably gdb (the gnu debugger). Get these if you think you will need it!
OK: Now get the fltk tarball you want to build...
Lets say you have downloaded fltk-1.1.7.tar.bz2 from the website. How do you use that? (Note that these instructions ought to work for fltk-2.x tarballs to... more or less!)
Let's say you have made a directory on your D: drive, at D:\fltk.
Start your Msys shell and type:
(Note that the slashes are unix style forward slashes in Msys, NOT DOS style back-slashes. Try not to get that wrong, or Bad Things might happen!)
Now unroll the tarball:
tar -jxf fltk-1.1.7.tar.bz2
Then cd into the fltk-1.1.7 directory this creates:
Now you configure fltk for your system, using the standard auto-configuration process:
./configure --enable-threads --enable-localjpeg --enable-localzlib --enable-localpng
This tests your system and generates system specific header files to match your build tools.
In particular, note the lines like "--enable-localjpeg" and "--enable-localpng". These tell the configuration that you want to use the fltk built-in graphics libraries.
Use these if you do not have the graphics libraries installed already. If you *don't know* if you have them installed already, then it is a fair bet that you don't!
Which builds the library. When it is complete type:
Which will run the basic demo program and allow you the verify that the widgets have built OK. If all seems well, try:
Which will install the libraries and header file so that mingw can use them to build other projects.
NOTE: If that's all too much command-line oriented for you, google for Dev-Cpp, which is a full, free, IDE system based on mingw that works on Windows. There are "devpaks" distributed for it that should build fltk for you.
NOTE 2: This sequence of configure / make / make install is *identical* to what you need to do most other platforms to build fltk (or most open software), so these instructions work on Mac OSX, linux, other unix's, etc...
[ Listing ]
[ Submit Comment ]
From Stew_822, 20:17 Oct 17, 2010 (score=3)
I agree that this should be in the documentation, or something similar. I have been searching for days trying to compile this library and this method seems to be working. It should really be in a more accessible place :).
[ Reply ]
From Lofty089, 10:46 Mar 01, 2009 (score=3)
what about putting this HowTo into the Documentation part?
Since I found this tutorial, FLTK is working fine for me,
but I've been searching a very long time until I found it.
Would it be possible to put this into the Documentation section,
so that it can be found easily?
[ Reply ]
From josh2112, 17:43 Jan 18, 2007 (score=3)
Building shared DLLs using FLTK's native JPEG and PNG libraries:
./configure --enable-shared --enable-localjpeg --enable-localzlib --enable-localpng
Seems to be broken currently, see the long-running thread here:
[ Reply ]
From ianmacarthur, 02:53 Mar 04, 2007 (score=3)
Building shared (i.e. DLL's) of fltk with mingw is fixed now in recent snapshots of 1.1.8
[ Reply ]