FLTK in MSVC needs x11 headers?
Asked Answered
C

1

6

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.

Crescent answered 24/7, 2011 at 0:49 Comment(5)
have you defined WIN32 for the compilerOttoottoman
this is important to me, you are using fltk, what reason did you pick it up to use? any plans for it?Ottoottoman
Thanks for the Tip, I found adding either "#define WIN32 1" or "#include <windows.h>" before "#include <FL/Fl.h>" makes it work. But how do I get rid of the command line?Crescent
I presume you mean that console window. There's a linker option, that sets a flag in the executable if the console it to be opened or not. And unfortunately it's been so long I did that, that I can't remember the exact way to do it. I just know that it was something with the runtime library used.Arundinaceous
Ah, there it is: In the source file containing the int main(...) add this #pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup") or set this in the project build linker options.Arundinaceous
C
14

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

Crescent answered 25/7, 2011 at 18:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.