Using FLTK with Code::Blocks

FLTK is a easy to use, free GUI library.

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:

The path you entered seems valid, but the wizard can't locate the include directory. The wizard cannot continue.

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) Locate FltkPathDefaultInc 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).

3 Comments

  • Cryora says:

    Now it is saying that it cannot locate the FLTK library file.

    • richardsplanet says:

      Unfortunately, I can’t help you any further.

      The article was written 6 years ago and I no longer use FLTK or Code::Blocks.

      It is possible that they have changed things. You might try asking for help on the FLTK forum.

    • richardsplanet says:

      Unfortunately, I can’t help you any further.

      The article was written 6 years ago and I no longer use FLTK or Code::Blocks.

      It is possible that they have changed things. You might try asking for help on the FLTK forum or the Code::Blocks forum.