How to configure FLTK in NetBeans in Linux

Some instructions and screenshots to help you get up and running using the Fast Light Toolkit (FLTK) within the NetBeans development environment in Linux. For configuring FLTK in Visual Studio environments please refer to this post. Go to the FLTK website and download the latest source: http://www.fltk.org fltk8 Extract the tarball to your selected home directory using the following commands: [code language="cpp"] $ gunzip fltk-1.3.3-source.tar.gz $ tar -xvf fltk-1.3.3-source.tar [/code] Then navigate (cd) to the newly-created fltk directory and install: [code language="cpp"] $ ./configure $ make $ sudo make install [/code] It is also necessary to download and install the necessary libraries. Run the following command: [code language="cpp"] $sudo apt-get install libx11-dev libxpm-dev x11proto-xext-dev libxext-dev g++ [/code] For this example, we use an example "Hello World!" test program to test the functionality of FLTK and its dependencies. Create a new C++ application in NetBeans, using the following code as your main.cpp: [code language="cpp"] #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Box.H> int main(int argc, char **argv) { Fl_Window *window = new Fl_Window(300,180); Fl_Box *box = new Fl_Box(20,40,260,100,"Hello, World!"); box->box(FL_UP_BOX); box->labelsize(36); box->labelfont(FL_BOLD+FL_ITALIC); box->labeltype(FL_SHADOW_LABEL); window->end(); window->show(argc, argv); return Fl::run(); } [/code] There are still a number of things you will need to do before your example test program will successfully compile and run, which are now described in the following sections: Test FLTK with the test-config script You will need to determine what dependencies will be needed to run your FLTK project. Run the fltk-config script that comes with the FTLK installation: "--cxxflags" fltk1 From the console output we can see that this project will require the dependency: /usr/include/freetype2 "--ldflags" fltk2 From the console output we can see that this project will need the following linker flags: -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 "--ldstaticflags" fltk3 Configure the Include directories Right-click on your project and select Properties. Then select 'C++ Compiler' and then 'Include Directories'. Add the directory(s) obtained from the "cxxflags" command run previously: fltk4 Configure the Linker Right-click on your Project and select Properties. Then select "Linker" and then "Libraries". Click "Add Library" and add "libfltk.a". This can be found in the lib directory inside the fltk folder: fltk5 Configure Additional Options Add the options obtained through running the "ldflags" option described previously. In my case it was: -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 Right-click on your project and select Properties. Then select "Linker" and "Additional Options" and copy in the linker flag options: fltk6 The project should then be ready to compile and run: fltk7

Comments

Popular posts from this blog

Using the Supervisor Controller Pattern to access View controls in MVVM

Getting started with client-server applications in C++

How to send an e-mail via Google SMTP using C#