Compiling and Linking FLTK

Most likely you already have the OpenGL libraries on your PC. The DLLs should come with your Windows distribution. So you won't have to do much here.
The FLTK libraries, as well as fluid, you will have to compile yourself. Download the fltk-1.1 source zip file from www.fltk.org. Note, I used version 1.1.9 for these instructions. The fixes described below may not be totally same for other versions. In any case, version 1.1.9 is also still available. After unpacking you will find a few README files that explain what you have to do. These are the steps:

Build the fltk libraries:

  • Double-click on the workspace file fltk.sln in the 'vc2005' folder (if you use vc2005 or vc2008), or fltk.dsw in the 'visualc' folder (if you use vc6). This brings up VisualStudio and loads all the fltk source files into the workspace. Rebuild the whole solution in both the release version and the debug version. You will get fltk.lib for the release version, and the fltkd.lib for the debug version.
  • Note: I am using VC2008. Under VC2008, you might get build failures when you build the solution for the first time, especially for the debug version (I believe it is due to the building order). Anyway, what I did is just to build (not rebuilt) it a few more times, you should get it done well.
  • The end result are a few files in the 'lib' folder. Create a directory on your disk C:\..$blahblah$..\fltk and put the entire 'lib' folder there. Also, create a directory C:\..$blahblah$..\fltk\include and put the entire 'FL' folder from the fltk distribution there. So now you should have two folders: C:\..$blahblah$..\fltk\lib containing all fltk libs and C:\..$blahblah$..\fltk\include\FL containing all fltk .h (header) files.

Build the fluid GUI-builder program:

  • If you are using VC2008 (and maybe 2005), the fluid should already compile and link when you finished the above steps. You will find in the "fluid" directory a "fluid.exe" executable binary.
  • If you are using VC6 (or you didn't find this "fluid.exe"), exit VisualStudio and double-click on the fluid.dsw workspace file (if it does not exist double-click on the fluid.dsp project file) in the 'visualc' folder of your fltk distribution. In VisualStudio, make sure you select in Build->SetActiveConfigurations the item fluid - Win32Release (it may be set to fluid - Win32Debug). Before you build, you may need to add add both files fltkforms.lib and fltkimages.lib to the Project->Settings->Link, in Object/library modules. You also need to tell VC++ where to find the file. Choose Tools->Options->Directories, select 'library files' in the 'Show directories for:' selector. Now add in the empty slot: C:\..$blahblah$..\fltk\lib. Now hit 'Build->Rebuild All' and fluid will compile and link. After the link you will find a file fluid.exe in the fluid folder of your fltk distribution.
  • You can leave "fluid.exe" in the 'fluid' folder and create a shortcut on your desktop, or you can move it anywhere you like. To run fluid, double-click on the icon or the shortcut you created.
Notes: Both the fltk and the fluid documentation is available for browsing at http://www.fltk.org. It is also available off-line in the 'documentation' folder in your fltk distribution. Double-clicking the file index.htmlin that folder will bring up your favorite webbrowser. Make sure you make good use of the documentation. Read the fluid page for info on how to use this nifty little program. There is also a nice example on how to draw a cube with OpenGL. Learn how a Gui is built, maybe even build a small one yourself, and then go and expand the one that was already started for you.

A small tutorial on fluid:

Fluid offers a text editor as well as a visual editor that shows the actual GUI. You can move items around in the visual editor, but you need to add items in the text editor. First, load the provided gui.fl into fluid by selecting 'File - open' on the menubar of fluid's text editor. This should pop up the visual editor and fill some text into the text editor. Fluid is quite powerful, but for the matter of this class, you only need to know what is described below. However, feel free to read more about the capabilities of fluid on the documention pages at http://www.fltk.org.
To add a new submenu item for gui.fl:
  • Select the already existing 'Menu Bar menu bar' item in the text editor and then go to the 'New' pull down menu and select 'menus - submenus'.
  • A window will pop up where you can enter the properties of this submenu:
    • For 'Name' enter the name you want to give this item (for example 'imageProcess',
    • and for 'Label' enter the tag you want to appear on the GUI menu bar (for example 'Image Process').
    • You can click on 'OK' and you will see that submenu appear in the visual editor on the menu bar.
  • If you want to move it to the left of the 'Exit' button, you can select the 'imageProcess' item on the list and then choose 'Edit - earlier' on the fluid text editor menu bar.
To add a new menu item for a submenu in gui.fl:
  • select an already existing 'submenu' item in the text editor (for example 'imageProcess') and then go to the 'New' pull down menu and select 'menus - menu item'.
  • A window will pop up. Enter an appropriate name and label as before (for example 'update' and 'Update', respectively),
  • and in 'Callback' enter the name of the routine in the application class in Application.cpp that will service this callback (for example, enter the line: app->Update(); ).
  • Note that you must provide this routine in Application.cpp and also define it in Application.h before you compile the application with the new gui.cpp and gui.h (see below).
  • Select a few items in gui.fl (double clicking will bring up the property window for that item) that have already been defined to see how things are done. Select 'File - write code' which will write a new gui.cpp and gui.h. You may have to set the extension .cpp in 'Edit - preferences' (it may be set to .cxx). Note that you have to include gui.fl and gui.h into your Visual Studio project before you compile and link. Save the new gui.fl with 'File - save'.

Instructions on how to set up VC+ with FLTK

I used Visual Studio 8.0. These are what I have found to be the required additional settings in this environment (further below are instructions on how to compile FLTK 2.0 itself, if the computer you are using does not have it installed). 1. In Tools -> Options -> VC++ Directories add the paths to the fltk include files and libraries. 2. Project->Properties->Configurations-> Linker, in 'additional dependencies' add: odbc32.lib odbccp32.lib wsock32.lib opengl32.lib glu32.lib fltk2.lib fltk2_gl.lib comctl32.lib 3. Project->Properties->Configurations-> Linker, in 'ignore specific librar' add: LIBCMT 4. Make sure you add 'using namespace fltk' in every file right after the include statements