I think I may have discovered the problem. In a StackOverflow post (
https://stackoverflow.com/questions/33131740/compile-fltk-with-g), agold states that the linking parameters must be positioned after the source and header files. For example:
$ g++ fltk_mingw_test.cpp -lfltk -o fltk_mingw_test
.
The above command successfully compiles and builds an executable, but if I move
-lfltk so that it comes before the source code and header files:
$ g++ -lfltk fltk_mingw_test.cpp -o fltk_mingw_test
I get the following error messages:
C:/ProgramFiles/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\ProgramFiles\msys64\tmp\cc99H6gV.o:fltk_mingw_test.cpp:(.text+0x38): undefined reference to `Fl_Window::Fl_Window(int, int, char const*)'
C:/ProgramFiles/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\ProgramFiles\msys64\tmp\cc99H6gV.o:fltk_mingw_test.cpp:(.text+0x76): undefined reference to `Fl_Box::Fl_Box(int, int, int, int, char const*)'
C:/ProgramFiles/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\ProgramFiles\msys64\tmp\cc99H6gV.o:fltk_mingw_test.cpp:(.text+0xb6): undefined reference to `fl_define_FL_SHADOW_LABEL()'
C:/ProgramFiles/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\ProgramFiles\msys64\tmp\cc99H6gV.o:fltk_mingw_test.cpp:(.text+0xcc): undefined reference to `Fl_Group::end()'
C:/ProgramFiles/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\ProgramFiles\msys64\tmp\cc99H6gV.o:fltk_mingw_test.cpp:(.text+0xe2): undefined reference to `Fl_Window::show(int, char**)'
C:/ProgramFiles/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\ProgramFiles\msys64\tmp\cc99H6gV.o:fltk_mingw_test.cpp:(.text+0xe7): undefined reference to `Fl::run()'
collect2.exe: error: ld returned 1 exit status
Although the functions in the error message are different from those generated by SlickEdit, the error "undefined reference" is the same. This would seem to suggest that if SlickEdit moved the -l parameter so that it is positioned after the source and header files, then the following code would compile:
#include <iostream>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include "fltk_mingw_test.h"
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();
}
In the build output, I'm unable to make out what command is being executed. Is it possible that SlickEdit is not positioning the -l parameter so that it comes after the source and header files?