1

I have a simple little program (nominated hello_fltk.cpp), (I use Ubuntu), that I attach below:

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

#include <string>

int main(int argc, char **argv) {
  const std::string hw_s = "Hello, World!";
  Fl_Window *window = new Fl_Window(340, 180);                 
  Fl_Box *box = new Fl_Box(20, 40, 300, 100, hw_s.c_str());  

  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);      
  Fl::run();                    
  return 0;
}

ok, now when I compile it, I write on the terminal : g++ hello_fltk.cpp. The errors that I found are

/tmp/ccfyku2b.o: In function `main':
hello_fltk.cpp:(.text+0x70): undefined reference to `Fl_Window::Fl_Window(int, int, char const*)'
hello_fltk.cpp:(.text+0xb0): undefined reference to `Fl_Box::Fl_Box(int, int, int, int, char const*)'
hello_fltk.cpp:(.text+0xf0): undefined reference to `fl_define_FL_SHADOW_LABEL()'
hello_fltk.cpp:(.text+0x106): undefined reference to `Fl_Group::end()'
hello_fltk.cpp:(.text+0x11b): undefined reference to `Fl_Window::show(int, char**)'
hello_fltk.cpp:(.text+0x120): undefined reference to `Fl::run()'
collect2: error: ld returned 1 exit status

So there are undefined references, but I correctly installed all the functions that are reported as not found, so maybe I'm compiling wrong. Can anyone help me fix this linker error? Thanks in advance!

Ale
  • 11
  • 2
  • O.T.: If you intend to publish your error diagnostics in SO, you could set `LANG=C` in that terminal before compiling. – Scheff's Cat Mar 18 '21 at 10:47
  • This is not even related to OpenGL, the errors are only from FLTK. – BDL Mar 18 '21 at 10:56
  • There is an error in your code, 2nd row: it should be `#include ` and not only ``. Moreover, you can find how to compile code using FLTK [here](https://www.fltk.org/doc-1.3/basics.html#basics_standard_compiler). – Eddymage Mar 24 '21 at 08:56

0 Answers0