I just installed FLTK library on Linux with the standard commands: cmake .. / make / sudo make install
My understanding is that "make install" moved the library to /usr/local/include. And I found the folder there:
[ken@Lnx include]$ pwd
/usr/local/include
[ken@Lnx include]$ ls
FL
Now I want to run the test from "Programming Principle and Practice" with the code:
#include <FL/Fl.h>
#include <FL/Fl_Box.h>
#include <FL/Fl_Window.h>
int main()
{
Fl_Window window(200, 200, "Window title");
Fl_Box box(0, 0, 200, 200, "Hey, I mean, Hello, World!");
window.show();
return Fl::run();
}
Initially I had include errors, but then I noticed the files in the FL folder have .H and not .h extensions.
They disappeared after changing that in the code .
But now I have this compile error:
ken@Lnx fltk_test]$ g++ fltk_test.cpp
/usr/bin/ld: /tmp/ccJWfQR3.o: warning: relocation against `_ZTV6Fl_Box' in read-only section `.text._ZN6Fl_BoxD2Ev[_ZN6Fl_BoxD5Ev]'
/usr/bin/ld: /tmp/ccJWfQR3.o: in function `main':
fltk_test.cpp:(.text+0x37): undefined reference to `Fl_Window::Fl_Window(int, int, char const*)'
/usr/bin/ld: fltk_test.cpp:(.text+0x62): undefined reference to `Fl_Box::Fl_Box(int, int, int, int, char const*)'
/usr/bin/ld: fltk_test.cpp:(.text+0x71): undefined reference to `Fl_Window::show()'
/usr/bin/ld: fltk_test.cpp:(.text+0x76): undefined reference to `Fl::run()'
/usr/bin/ld: fltk_test.cpp:(.text+0x97): undefined reference to `Fl_Window::~Fl_Window()'
/usr/bin/ld: fltk_test.cpp:(.text+0xd0): undefined reference to `Fl_Window::~Fl_Window()'
/usr/bin/ld: /tmp/ccJWfQR3.o: in function `Fl_Box::~Fl_Box()':
fltk_test.cpp:(.text._ZN6Fl_BoxD2Ev[_ZN6Fl_BoxD5Ev]+0xf): undefined reference to `vtable for Fl_Box'
/usr/bin/ld: fltk_test.cpp:(.text._ZN6Fl_BoxD2Ev[_ZN6Fl_BoxD5Ev]+0x22): undefined reference to `Fl_Widget::~Fl_Widget()'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
I use Visual Studio Code Insiders and I configured "settings.json" to have these default settings that I wanted to make visible the library to future projects:
"C_Cpp.default.compilerPath": "/usr/bin/gcc",
"C_Cpp.default.includePath": ["/usr/local/include/"],
I configured "c_cpp_properties.json" with the same settings, that overwrites the default settings from "settings.json".
But I get the same errors.
What else can I do? Thanks for your reply!