How to build FLTK with QT Creator and Ubuntu

The IDE I like to work with when programming C++ is Qt Creator. The library used in Programming: Principles and Practice using C++ is FLTK. Figures out that it is really easy to make it work under Ubuntu but I was struggling to find exact instructions for some reason. (Well, may be because most of linux guys know what they are doing unlike me 🙂 ).

Ok, here is what needs to be done.

First, fltk is available under in ubuntu as the package libfltk.

Type


sudo apt-get install libfltk1.3

Next, locate the folder that  contains the library using. You are looking for .so file.


sudo dpkg -L libfltk1.3

You will see something like  /usr/lib/x86_64-linux-gnu/libfltk.so.1.3  as one of the files that depend on the package.

I am assuming that you are using qmake. Then add this line to your project.

LIBS += /usr/lib/x86_64-linux-gnu/libfltk.so.1.3

To check that everything is working, try to compile the following program.

#include <FL/Fl.h>;
#include <FL/Fl_Box.h>;
#include <Fl/Fl_Window.>

int main() {
  Fl_Window window{200, 200, "Window title"};
  Fl_Box box{0, 0, 200, 200, "Hey, I mean hello world\n"};
  window.show();
  return Fl::run();
}
You should see a window with a message.

Have fun learning to program graphics!

 

One thought on “How to build FLTK with QT Creator and Ubuntu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s