Saturday, June 26, 2010

How-to Setup FLTK on Ubuntu Using the Netbeans IDE

This blog post shows you how to get the FLTK Fast Light Toolkit up and running on Ubuntu using Netbeans 6.9 IDE.



As a disclaimer I am much more of a software engineer than a system administrator. If I did anything that is less than optimal feel free to let me know. Yet I could not find any instructions on the internet that showed how to setup FLTK on Ubuntu with Netbeans so I wrote them up.


Download FLTK
  1. http://www.fltk.org/ 
  2. Extract  fltk-1.1.10 to your home directory
Download Necessary Libraries
  1.  sudo apt-get install libx11-dev libxpm-dev x11proto-xext-dev libxext-dev g++
 Compile FLTK
  1. cd to /home/fltk-1.1.10
  2. sudo ./configure
  3. sudo make
  4. sudo make install
Test FLTK with fltk-config 

 
FLTK comes with a script called "fltk-config" this script has many helpful options. If you want to simply test your FLTK installation you can use this script to compile your FLTK application by typing: "fltk-config --compile myTest.cpp" You will also need to use the "--cxxflags", "--ldflags", and "--ldstaticflags" to figure out how to setup Netbeans.







"--cxxflag" 
My output was as follows:
"-I. -I./png -I./zlib -I./jpeg"

This means that FLTK relies on header files contained in:
  • fltk-1.1.10
  • fltk-1.1.10/png 
  • fltk-1.1.10/zlib
  • fltk-1.1.10/jpeg
Netbeans will use those directories to provide code assistance.


"--ldflags"
My output was as follows:
"-L./lib -lfltk -ldl -lm -lXext -lX11"

This means we must set the linker to point to the /lib directory within fltk-1.1.10.

"--ldstaticflags"
My output was as follows:
"./lib/libfltk.a -ldl -lm -lXext -lX11"


Configure Netbeans 6.9

Step 1 - Configure C++ Settings













  1. Right Click on Project and Click Properties
  2. Click "C++ Compiler"
  3. Click "Include Directories"
  4. Add the Directories shown in image above



Step 2 - Configure Linker

















  1. Right Click on Project and Click Properties
  2. Click "Linker"
  3. Click "Libraries"
  4. Click "Add Library"
  5. Add "libfltk.a"


















  1. Click Additional Options
  2. Add "-ldl -lm -lXext -lX11"


Step 3 - Configure Output Window




















If everything worked alright you should be able to build and run FLTK applications! Visit http://www.fltk.org/doc-1.1/basics.html#basics for some sample code!



5 comments:

  1. Good job done, thanks it works.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. You can also place fltk-config in a directory accessible on PATH, and add `fltk-config --cxx-flags` (note the backticks!) to Compiler->Additional Options, and `fltk-config --use-XXX --ldflags` (note the backtics!) to Linker->Libraries as Option (not to Linker->Additional Options!) - where --use-XXX would be e.g. --use-forms :)

    ReplyDelete
  4. Some App Example maybe ? ^__^ Text Editor ?

    ReplyDelete
  5. Thank you. Clear, concise and very helpful.

    ReplyDelete