Not sure... This is a “works for me” sort of answer, but here’s some code I use. This is pretty old, so there may be better fltk’ish ways these days, but this (still) works for me.
So, amongst the headers, ifdef’d for X11 builds I have:
# include <X11/xpm.h>
# include "media/fn5x64.xpm”
Then in main(), just before I show the main window I have (also suitably ifdef’d, of course...)
fl_open_display(); // Make sure the display is available before we try and change it!
Pixmap pixmap, mask; // create pixmaps to hold the icon image and its mask
// load the XPM and prepare the mask
XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display), (char**)fn5x64_xpm_data, &pixmap, &mask, 0);
// assign to the fltk main window
// note that the fltk icon handling DOES NOT honour transparency,
// so we fix that AFTER the window is shown (see below)
main_window->icon((char*)pixmap);
/* Show the main window */
main_win->window->show();
Then after the window is mapped I fix up icon transparency issue with:
// The fltk icon code doesn't handle XPM transparency well, work around that here...
{
// read in the current window hints, then modify them to allow icon transparency
XWMHints* hints = XGetWMHints(fl_display, fl_xid(main_window));
hints->flags |= IconMaskHint; // ensure transparency mask is enabled for the XPM icon
hints->icon_mask = mask; // set the transparency mask
XSetWMHints(fl_display, fl_xid(main_window), hints);
XFree(hints);
}
And that’s pretty much it...
I’ve no clue what causes the compiler issue you are seeing.