CIS-255 Home:

Installing FLTK with Visual Studio

  1. FLTK Install with Visual Studio
  2. Downloading FLTK
  3. Building FLTK library
  4. Adding FLTK library to Visual Studio
  5. Testing how it all works

FLTK Install with Visual Studio

Downloading FLTK

Building FLTK library

  1. Navigate to folder

  2. Double-click the file named fltk.sln. It opens a large MSVC++ solution that includes FLTK demo apps and the library itself. Be patient, as it takes almost a minute to load all parts into Visual Studio development environment.

  3. Since FLTK is distributed as open source software, you must build the library on our own machine. Go to Visual Studio menu

        Build -> Configuration Manager...

    and switch active configuration to Release.

  4. Click Visual Studio menu

        Build -> Rebuild Solution

    Be patient as the surce code is being compiled. It will take several minutes to finish. If everything is okay, you should see a message similar to

        ========== Rebuild All: 79 succeeded, 0 failed, 0 skipped ==========

    at the end.

  5. Exit Visual Studio.


Adding FLTK library to Visual Studio

Testing how it all works

  1. Start Visual Studio again.

  2. Click

        File -> New -> Project

    Select Win32 Project for the project type. Choose a name, e.g. fltk_win32_app, and change project location to


    or something similar. Click Next on the project wizard screen and check "Empty project" option, then Finish.

  3. Click

        View -> Solution Explorer
  4. Right-click on Source Files and choose

        Add -> New item...

    Use C++ File (.cpp) for the type of the file. Name it main.cpp.

  5. The empty main.cpp file automatically opens in the editor. Copy and paste the following code:

    #include <Windows.h> // include Windows.h only if using WinMain
    #include <FL/Fl.H>
    #include <FL/Fl_Box.H>
    #include <FL/Fl_Window.H>
    // Use standard main to have console background:
    // int main()
    // Use WinMain if you don't want the console in the background:
    int __stdcall WinMain(
        __in HINSTANCE hInstance,
        __in_opt HINSTANCE hPrevInstance,
        __in LPSTR lpCmdLine,
        __in int nShowCmd
        Fl_Window window( 200, 200, "My window title" );
        Fl_Box box( 0, 50, 200, 20, "Hello" );;
        return Fl::run();
  6. In the Solution Explorer, right-click fltk_win32_app project and select Properties. You need to make the following three changes:

        Configuration Properties
                Code Generation
                    Runtime Library
                            and set it to Multi-threaded DLL (/MD)
                    Additional Dependecies
                            and enter fltk.lib
                    Ignore Specific Default Libraries
                            and enter libcd.lib

    For example,

      Additional Dependecies

    Click OK and save your changes.

  7. Click Visual Studio menu

        Build -> Rebuild Solution
  8. Press F5 to run the program.

  9. Everything should compile and run without any problems. If you do get an error, send me an email, so I can look at the issue.