FLTK in MSVC needs x11 headers?

2019-02-18 10:32发布

问题:

I'm trying to learn how to use FLTK right now (In MSVC 2008). I got all the the libraries compiled correctly, but when I tried to run this program:


    #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(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();

        return Fl::run();
    }

I got this error


    1>c:\fltk\fl\xutf8.h(33) : fatal error C1083: Cannot open include file: 'X11/X.h': No such file or directory

I can tell that it is missing x11, but I did a quick google search, and I couldn't find any help on this subject. BTW, I'm running v1.3.0.

Thanks for your time.

回答1:

I found the answer, add "#define WIN32" before your FLTK includes.