PDA

View Full Version : Use FLTK libraries with QtCreator



giorgik
9th December 2012, 09:00
Hello everybody, I need to know how to integrate in a project created with QtCreator 4.6.2 libraries FLTK 1.3.1. The Operating System is Windows XP, and the compiler is MinGW 4.6.2.
How do I write to the file. Pros to use the libraries FLTK ? Someone has never used ?

amleto
9th December 2012, 10:31
same as any other library. Add the include dirs and library dirs to your pro file. See the documents for help and example pro files.

giorgik
9th December 2012, 11:38
the problem is that it is not sufficient. Can not find references to objects of the FLTK library libfltk.a:
Fl.cxx: -1: error: undefined reference to `OleUninitialize @ 0 '
I put the following lines in my. pro:


QT += core
QT -= gui
TARGET = fltk_hello
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app

#------------------------------------------------
#
# Uso librerie FLTK 1.3.1
#
#------------------------------------------------
INCLUDEPATH += C:/MinGW/include \
C:/MinGW/FLTK/include

LIBS += C:/MinGW/FLTK/lib/libfltk.a \
C:/MinGW/FLTK/lib/libfltk_forms.a \
C:/MinGW/FLTK/lib/libfltk_gl.a \
C:/MinGW/FLTK/lib/libfltk_images.a \
C:/MinGW/FLTK/lib/libfltk_jpeg.a \
C:/MinGW/FLTK/lib/libfltk_png.a \
C:/MinGW/FLTK/lib/libfltk_z.a

SOURCES += main.cpp

amleto
9th December 2012, 12:48
then you're either missing some #defines to import symbols correctly (if importing shared libraries), or you haven't linked with the correct libraries, or perhaps something else is wrong.

giorgik
9th December 2012, 14:56
To compile the FLTK library 1.3.1 I used CMake and then make MinGW. The sample code used is based on FLTK:


//#include <QCoreApplication>

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>

int main(int argc, char *argv[])
{
//QCoreApplication a(argc, argv);

Fl_Window *window = new Fl_Window(340,180);
Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!");
box->box(FL_UP_BOX);
box->labelfont(FL_BOLD+FL_ITALIC);
box->labelsize(36);
box->labeltype(FL_SHADOW_LABEL);
window->end();
window->show(argc, argv);
return Fl::run();

//return a.exec();
}


I do not understand what is missing... No one has ever used the FLTK?

amleto
9th December 2012, 15:17
why dont you ask on a fltk forum? This is a Qt programming forum, and your question has nothing to do with qt programming.

giorgik
10th December 2012, 12:13
Ok, I wrote in the forum FLTK - general. Let's see what they tell me. But then you have to act on the file .pro of QtCreator to build the project

giorgik
14th December 2012, 08:38
Found the solution. Having the libraries FLTK 1.3.1 compiled (it can be easily done using the shell of MSYS (rxvt) with MinGW 4.6.2), this is to give the MSYS (rxvt) shell prompt the following command:


fltk-config --ldstaticflags

in this way we obtain the flags necessary for the compilation of any example of using FLTK MinGW and consequently amche our beloved Qt Creator 2.6.0
In my case for example I got:
-mwindows /usr/local/lib/libfltk.a -lole32 -luuid -lcomctl32
Please note that:
/usr/local/ is in
C:\MinGW\msys\1.0\local
So in the project file of Qt we get:


#------------------------------------------------
#
# Uso librerie FLTK 1.3.1
#
#------------------------------------------------
INCLUDEPATH += C:/MinGW/include

LIBS += -mwindows C:/MinGW/lib/libfltk.a \
C:/MinGW/lib/libfltk_forms.a \
C:/MinGW/lib/libfltk_gl.a \
C:/MinGW/lib/libfltk_images.a \
C:/MinGW/lib/libfltk_jpeg.a \
C:/MinGW/lib/libfltk_png.a \
C:/MinGW/lib/libfltk_z.a \
-lole32 -luuid -lcomctl32

For the curious here is the procedure to follow to compile the libraries FLTK 1.3.1 with MinGW 4.6.2 using MSYS (rxvt):
1- copy the file fltk-1.3.1-source.tar.gz in /home/your-username/ of msys\1.0\ then give the command to
MSYS shell (rxvt):

tar xvzf fltk-1.3.1-source.tar.gz
2-
cd fltk-1.3.1
3-
./configure & make & make install will be installed in /usr/local/lib, /usr/local/include/FL, /usr/local/bin, /usr/local/share. Please note that /usr/local is C:\MinGW\msys\1.0\local
Have fun with FLTK