1. Get the source from fltk.org.
2. Unpack the archive using
tar -xf [fltk archive filename]
3. Run
make install
.That's all!
A simple hello world:
#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(320, 240);
Fl_Box* box = new Fl_Box(20,20,40,40,"Button");
box->box(FL_UP_BOX);
window->end();
window->show(argc, argv);
return Fl::run();
}
You can check it out with
fltk-config --compile main.cpp
.If you use the standard way (e.g. clang++ main.cpp), you might get lots of undefined references like these:
/tmp/source1-be00e7.o: In function `main':
source1.cpp:(.text+0x44): undefined reference to `Fl_Window::Fl_Window(int, int, char const*)'
source1.cpp:(.text+0x93): undefined reference to `Fl_Box::Fl_Box(int, int, int, int, char const*)'
source1.cpp:(.text+0xbd): undefined reference to `Fl_Group::end()'
source1.cpp:(.text+0xcd): undefined reference to `Fl_Window::show(int, char**)'
source1.cpp:(.text+0xd2): undefined reference to `Fl::run()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You can easily remedy this:
clang++ main.cpp `fltk-config --cxxflags --ldstaticflags`
No comments:
Post a Comment