Missing library when building an FLTK application on Eclipse

101 Views Asked by At

I have installed FLTK using home-brew on my Intel 64 MacBook and Mac OS. In have made a C++ project in Eclipse and copy/pasted the Hellow World example from the FLTK documentation. I can compile the module without errors, but the link always fails saying it cannot find or load the library libfltk.a.

The output, including the error message, from the build is:

Building target: helloWorld
Invoking: MacOS X C++ Linker
g++ -L/usr/local/lib/ -L/Users/guyhbroadfoot/eclipse-workspace/helloWorld/lib/ -o "helloWorld"  ./src/helloWorld.o    -llibfltk.a
ld: library not found for -llibfltk.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [helloWorld] Error 1
make: *** [all] Error 2
"make all" terminated with exit code 2. Build might be     incomplete.

15:43:51 Build Failed. 3 errors, 0 warnings. (took 2s.531ms)
-

The helloWorld.cpp is cut/paste from the example in the FLTK manual as follows:

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

int main(int argc, char **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();
}

Homebrew installed the FLTK static libraries in /usr/local/lib which is a default search location for Eclipse. It also installs the include files in /usr/local/include/FL and the compiler finds these without any trouble. I have tried adding an explicit /usr/local/lib path to the linker settings in Eclipse and it generates the command correctly with this -L setting. I have also told it to use the library libfltk.a and it tries to do this, but always reports it cannot find it.

I have searched for help on this, but all suggestions seem to assume I want to download the FLTK source and build it myself, which I don't, really. I had hoped the installation via home-brew was all I would need to do.

Has anyone succeeded in building a program using FLTK installed via home-brew without rebuilding the FLTK libraries themselves from scratch?

Any ideas would be gratefully received. I have done the usual things, RTFM etc before calling for help.

0

There are 0 best solutions below