Complete, Concrete, Concise

Practical information without the bloat

Using FLTK with Code::Blocks

While Code::Blocks provides a FLTK project option, the problem is that it doesn’t work correctly. This is because Code::Blocks expects the FLTK include directory to be somewhere else.

These instructions are for FLTK 1.3.2 and Code::Blocks 12.10 or Code::Blocks 13.12 running on Windows 7.

The instructions are probably the same for other version combinations, but no guarantee is made.

Assumes you have already built and installed the FLTK libraries.

When you try to create a FLTK project using Code::Blocks, after you enter your FLTK directory, you are presented with the following error message:

This occurs because the Code::Blocks wizard is pretty stupid and expects header files to be found in a /include directory. FLTK, puts its header files in the directory /FL.

The function at fault is GetCompilerIncludeDir found in the file common_functions.script located in the ..\CodeBlocks\templates\wizard directory.

Solution #1

Note: this does not work for Code::Blocks 13.12

This is the easiest solution, but it changes the FLTK directory structure – it also means you have file duplication (if you choose the copy option).

1) Create an include directory in your FLTK directory:

2) Copy (or move) the FL folder into the include directory.

Solution #2

A little more complicated, but preserves the FLTK directory structure.

This requires editing the FLTK wizard script.

1) Open the file wizard.script. This is located in the

..\CodeBlocks\share\CodeBlocks\templates\wizard\fltk directory.

If you used the standard Code::Blocks install, it is probably located in the C: drive at C:\Program Files (x86)\CodeBlocks\share\CodeBlocks\templates\wizard\fltk.

If the file is located in C:\Program Files (x86)... then you will probably have difficulty editing it because, as a security feature, Windows 7 (and other versions) prevent anyone other than an administrator from editing content in that directory.

You will need to open a file editor with administrator privileges to be able to edit the file.

Instructions on how to open a file editor with administrator privileges can be found here.

2) LocateFltkPathDefaultInc and change#fl.fl to #fl for the line :

For Code::Blocks 13.12, you change #fl.include to #fl.

3) Comment out (or delete) the entire function OnLeave_FltkPath(fwd) (you can use the standard C++ single line comment // to comment out each line):

4) Restart Code::Blocks (if Code::Blocks was open when you made these changes).