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.

Benjamin
  • 1,223
  • 1
  • 13
  • 22
  • 4
    have you defined WIN32 for the compiler – marinara Jul 24 '11 at 00:54
  • this is important to me, you are using fltk, what reason did you pick it up to use? any plans for it? – marinara Jul 24 '11 at 00:54
  • Thanks for the Tip, I found adding either "#define WIN32 1" or "#include " before "#include " makes it work. But how do I get rid of the command line? – Benjamin Jul 24 '11 at 02:53
  • 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. – datenwolf Jul 30 '11 at 10:12
  • 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. – datenwolf Jul 30 '11 at 10:14

1 Answers1

14

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

Benjamin
  • 1,223
  • 1
  • 13
  • 22