LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   fltk error (https://www.linuxquestions.org/questions/linux-newbie-8/fltk-error-4175465692/)

invoices 06-12-2013 06:01 AM

fltk error
 
Hello,
I'm having troubles using FLTK.

I found following code snapshot in some fltk tutorial:

Code:

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
using namespace std;

//--------------------------------------------
void but_cb( Fl_Widget* o, void*  ) {
  Fl_Button* b=(Fl_Button*)o;
  b->label("Good job"); //redraw not necessary
 
  b->resize(10,150,140,30); //redraw needed
  b->redraw();
}

//--------------------------------------------
int main() {

    Fl_Window win( 300,200,"Testing" );
    win.begin();
      Fl_Button but( 10, 150, 70, 30, "Click me" );
    win.end();
    but.callback( but_cb );
    win.show();
    return Fl::run();
}

If I try to run this we eclipse, I'm getting following error:

Code:

11:58:45 **** Incremental Build of configuration Debug for project fltk ****
make all
Building target: fltk
Invoking: Cross G++ Linker
g++  -o "fltk"  ./src/fltk.o 
../src/fltk.cpp:9: error: undefined reference to 'Fl_Widget::label(char const*)'
../src/fltk.cpp:12: error: undefined reference to 'Fl_Widget::redraw()'
../src/fltk.cpp:18: error: undefined reference to 'Fl_Window::Fl_Window(int, int, char const*)'
../src/fltk.cpp:19: error: undefined reference to 'Fl_Group::begin()'
../src/fltk.cpp:20: error: undefined reference to 'Fl_Button::Fl_Button(int, int, int, int, char const*)'
../src/fltk.cpp:21: error: undefined reference to 'Fl_Group::end()'
../src/fltk.cpp:23: error: undefined reference to 'Fl_Window::show()'
../src/fltk.cpp:24: error: undefined reference to 'Fl::run()'
../src/fltk.cpp:24: error: undefined reference to 'Fl_Window::~Fl_Window()'
../src/fltk.cpp:24: error: undefined reference to 'Fl_Window::~Fl_Window()'
/usr/local/include/FL/Fl_Button.H:75: error: undefined reference to 'vtable for Fl_Button'
/usr/local/include/FL/Fl_Button.H:75: error: undefined reference to 'Fl_Widget::~Fl_Widget()'
collect2: ld gab 1 als Ende-Status zurück
make: *** [fltk] Fehler 1

11:58:45 Build Finished (took 115ms)

I'm facing the same problem in a different project that uses fltk with qtcreator. I'm using Ubuntu 12.04 64bit running on a i5 notebook (acer 4820tg).

Thank you

knudfl 06-13-2013 03:29 AM

Welcome to LQ.

The above example is for fltk version 1.1.6
Ref. http://www3.telus.net/public/robark/

If you have installed "libfltk1.1-dev" + "fltk1.1-doc" :
The 1.1.10 examples are in /usr/share/doc/fltk1.1-doc/examples/

And if you have installed "libfltk1.3-dev" + "fltk1.3-doc" :
/usr/share/doc/fltk1.3-doc/examples/

Ref. http://www.fltk.org/documentation.php/doc-1.1/toc.html
>>> http://www.fltk.org/documentation.ph....html#examples

-

invoices 06-13-2013 05:29 AM

Thank you for your reply.

I have installed following libraries: fltk1.1-doc libfltk1.1 libfltk1.1-dbg libfltk1.1-dev.
Unfortunately, I'm not able to run this example. Can you tell me the right steps to get it compiled ?

Thank you

knudfl 06-13-2013 05:57 AM

# 3 .
Quote:

I'm not able to run this example
Which example ?

If it's about the example in post #1 : Is for "old fltk" only : 1.1.6.
Please read http://www3.telus.net/public/robark/ : Year 2005.

FLTK versions are not compatible. Hence two versions in Ubuntu.

Some other Linux OS also have fltk-2.0.0 included :
I.e. we have three contemporary version, not compatible with each other.
And then we have the old versions.

-


All times are GMT -5. The time now is 04:09 PM.