1 README.MSWindows.txt - 2010-10-25 - Building FLTK under Microsoft Windows
2 -------------------------------------------------------------------------
10 2 HOW TO BUILD FLTK USING MinGW/Cygwin
12 2.2 Recommended Command Line Build Environment
14 2.4 Downloading and Unpacking
19 2.9 Creating new Projects
20 3 HOW TO BUILD FLTK USING VISUAL STUDIO 2008
22 3.2 Downloading and Unpacking
27 3.7 Creating new Projects
28 4 HOW TO BUILD FLTK USING VISUAL STUDIO 2010
30 4.2 Downloading and Unpacking
35 4.7 Creating new Projects
36 5 FREQUENTLY ASKED QUESTIONS
44 FLTK 1.3 and later is officially supported on Windows (2000,) 2003,
45 XP, and later. Older Windows versions are not officially supported,
46 but may still work. The main reason is that the OS version needs
47 to support UTF-8. FLTK 1.3 is known to work on Windows 7 and Vista.
49 FLTK currently supports the following development
50 environments on the Windows platform:
52 - Free Microsoft Visual C++ 2008 Express and Visual
53 C++ 2010 Express using the supplied workspace and
54 project files. Older and the commercial versions can
55 be used as well, if they can open the project files.
56 Be sure to get your service packs!
58 The project files can be found in the ide/ directory.
59 Please read ide/README.IDE for more info about this.
61 - GNU toolsets (Cygwin or MinGW) hosted on Windows.
63 CAUTION: Libraries built by any one of these environments can not be mixed
64 with object files from any other environment!
67 HOW TO BUILD FLTK USING MinGW and Cygwin
68 ==========================================
70 This chapter of this document gives a brief overview of
71 compiling and using FLTK with the Cygwin and MinGW compiler
72 toolkits. Both toolkits provide a build environment based
73 around the GNU C/C++ compiler. Further information is
74 available from the FLTK website at http://www.fltk.org, such
75 as this Howto note: http://www.fltk.org/articles.php?L598
77 The Cygwin build environment supplies a library (the Cygwin
78 DLL) that is primarily intended to provide a number of
79 Unix-like POSIX facilities for programs being ported to the
80 Windows environment (Win32 or WinNT). Cygwin also supplies
81 a very Unix-like build environment for Windows, including
82 the "BASH" Bourne-compatible shell and all of the standard
83 Unix file utilities (ls, cat, grep, etc.).
85 Cygwin is developed by Cygnus (now part of RedHat, Inc).
86 Although provided for free download under the GPL,
87 distributing programs that require the Cygwin DLL under a
88 license other than the GPL requires a commercial license for
89 the Cygwin DLL. Native Windows programs that do not require
90 the Cygwin DLL (compiled and linked with the "-mno-cygwin"
91 option) may be released under any license freely.
93 Note: Since December 2009, there is a new gcc 4.x compiler
94 that doesn't support the -mno-cygwin option anymore. You
95 must use the older gcc-3 compiler instead.
97 An alternative is to install the new (since about Oct. 2010)
98 mingw cross tools that support newer gcc compilers for building
99 native Windows applications (like -mno-cygwin above).
100 Currently you would have to install mingw64-i686-gcc-g++ for
101 32-bit Windows applications (despite its name!), and/or
102 mingw64-x86_64-gcc-g++ for 64-bit applications. You may also
103 need to install the corresponding '-headers' packages as well.
104 Currently these tools support gcc 4.5.x or newer, but the
105 setup for FLTK is somewhat more complicated and not yet
106 completely supported automatically (you may need to edit
107 some lines in the generated makeinclude file).
109 The MinGW distribution (Minimalist GNU for Windows) provides
110 a similar toolset but geared solely towards native Windows
111 development without the Unix-like POSIX library. The lack of
112 any libraries under the GPL or any other restrictive license
113 means that programs built with the MinGW environment may
114 always be released under any license freely. MinGW also
115 supplies a Unix-like build environment for Windows,
116 including MSYS (a Bourne-compatible shell) and the standard
117 Unix file utilities (ls, cat, grep, etc.)
119 If you are not familiar with these GNU-like toolkits please
120 refer to the links section later in this note. In particular,
121 check out their license conditions carefully before use.
127 There are currently three main configurations supported by
128 FLTK with the GNU tools:
130 1. Cygwin: Built using the Cygwin toolset and using the
131 Unix-like POSIX compatibility layer provided by the
134 2. Cygwin using the "-mno-cygwin" option: Built using
135 the Cygwin toolset but not using the Cygwin DLL.
137 3. MinGW: Built using the MinGW utilities, compiler and
138 tools. This is, in many aspects, analogous to the
139 Cygwin "-mno-cygwin" option. This is the recommended
140 one if you want to build native Windows programs only.
143 Recommended Command Line Build Environment
144 --------------------------------------------
146 Our recommendation is to:
148 1. Get the current Cygwin toolset.
150 This can either produce executables that do or do not
151 rely on the Cygwin DLL (check licensing) at your
154 2. Get the latest MinGW toolset. It is recommended that
155 you also get the MSYS shell and the msysDTK developer
158 This will only produce normal Windows native
159 executables without any Unix or POSIX compatibility
163 See the links section below for more information.
165 Either option can generate windows-native executables and
166 option 1 can provide a Unix-like POSIX portability layer that
167 is reliant on a GPLed library.
169 See the later sections for detailed information about using
170 one of these configurations.
176 In order to build FLTK from the command line, you need to install the MinGW
177 environment from www.mingw.org. The graphical installer "mingw-get-inst" can
178 be downloaded here for free:
180 http://www.mingw.org/wiki/Getting_Started
182 Launch the installer and follow the instructions. In the "Select Components"
183 dialog, add "C++ Compiler", "MSYS Basic System", and "MinGW Developer Toolkit".
184 Wait for the installer to finish.
186 After downloading and installing, you need to launch the MinGW Shell through
190 Downloading and Unpacking
191 ---------------------------
193 Download FLTK from here:
195 http://www.fltk.org/software.php
197 into your home folder. The default location as seen from MSWindows is similar
200 C:\MinGW\msys\1.0\home\matt\
202 If you are familiar with "subversion" and like to stay current with your
203 version, you will find the subversion access parameters at the bottom of
204 that page. Unpack FLTK into a convenient location. I like to have everything
210 tar xvfz fltk-1.3.xxxx.tar.gz
217 Stay in your FLTK source-code directory. Type:
221 Now configure your FLTK installation:
225 ADVANCED: type "./configure --help" to get a complete list of optional
226 configuration parameters. These should be pretty self-explanatory. Some
227 more details can be found in README.
230 The configuration script will check your machine for the required resources
231 which should all have been part of your MinGW installation. Review the
232 Configuration Summary, maybe take some notes.
234 ADVANCED: some versions of MinGW/Msys are broken and complain about a missing
235 --enable-auto-import. The solution is to upgrade to the current release. If
236 that is not possible, you can include the --enable-auto-import flag when
238 ./configure <config flags> LDFLAGS=-Wl,--enable-auto-import
245 Now this is easy. Stay in your FLTK source-code directory and type:
249 The entire FLTK toolkit including many test programs will be built for you.
250 No warnings should appear.
252 (actually, as of Oct 25 2010, quite a lot of warnings related to suggested
253 parentheses and others will appear, this is normal and will be fixed. The
254 linker will also spit out a bunch of warnings for every program linked. This
255 needs to be fixed. Lastly, there is no generator for man pages in a default
256 MinGW installation, but you can install man and groff to fix this.)
262 After a successful build, you can test FLTK's capabilities:
270 If you did not change any of the configuration settings, FLTK will be
271 installed in "/usr/local/include" and "/usr/local/lib" by typing
275 It is possible to install FLTK in user space by changing the installation path
276 to a location within the user account by adding the "--prefix=PREFIX" parameter
277 to the "./configure" command.
280 Creating new Projects
281 -----------------------
283 FLTK provides a neat script named "fltk-config" that can provide all the flags
284 needed to build FLTK applications using the same flags that were used to build
285 the library itself. Running "fltk-config" without arguments will print a list
286 of options. The easiest call to compile an FLTK application from a single
289 fltk-config --compile myProgram.cxx
291 "fltk-config" and "fluid" will be installed in "/usr/local/bin/" by default.
292 I recommend that you add it to the command search path.
296 HOW TO BUILD FLTK USING VISUAL STUDIO 2008
297 ============================================
303 In order to build FLTK from within VisualStudio 2008, you need to install the
304 VisualC developer environment from the Microsoft web site. The Express edition
305 is free of charge and sufficient to develop FLTK applications:
307 http://www.microsoft.com/express/Downloads/
309 You must make sure that at least VisualStudio 2008 Service Pack 1 is installed
310 or building FLTK on a multicore CPU will be very painful!
313 Downloading and Unpacking
314 ---------------------------
316 Download FLTK from here:
318 http://www.fltk.org/software.php
320 If you are familiar with "subversion" and like to stay current with your
321 version, you will find the subversion access parameters at the bottom of
324 Unpack FLTK by using an appropriate unpacker and copy the new folder into a
325 convenient location. I have set up a "dev" folder in my home folder for all
332 Launch VisualStudio. Open the project file in
334 ...\fltk-1.3.xxxx\ide\VisualC2008\fltk.sln
336 Choose "Debug" or "Release" mode from the "Solution Configurations" menu.
342 Use the context menu of the "demo" project to "Set as StartUp Project". Then
343 select "Build Solution" from the "Build" menu or press F7 to build all
346 VisualC 2008 has a bug that messes up building a Solution on multicore CPUs.
347 Make sure that Visual Studio 2008 Service Pack 1 is installed or, as a
348 workaround, set the "maximum number of parallel project builds" to 1 (Tools >
349 Options > Projects and Solutions > Build and Run > maximum number of parallel
350 project builds). Also, repeating the build command two or three times may
351 clear unresolved reference errors.
357 Select "Start Debugging" from the "Debug" menu or just press F5 to run the
358 Demo program. Use "Demo" to explore all test programs.
364 The default location for VisualC 2008 libraries and headers is here:
366 C:\Program Files\Microsoft Visual Studio 9.0\VC\
368 It is possible to move the FLTK libraries, headers, and Fluid into the
369 respective subdirectories, so that they are available for future development
370 without adding link and include paths to the solution.
372 copy the entire FL directory into the include path
374 copy all .lib files from the fltk lib directory to the VC lib directory
376 copy fluid.exe in the fluid directory to the bin directory
378 I highly discourage using dll's (dynamically linking libraries) on MSWindows
379 because they will require an installation process and likely cause version
380 conflicts. Use the static .lib libraries instead.
383 Creating new Projects
384 -----------------------
386 This chapter assumes that libraries and headers are copied into
388 C:\Program Files\Microsoft Visual Studio 9.0\VC\
390 Create a new project of type "General", "Empty Project" and add a simple "C++"
391 file to it. The FLTK "hello" source code is a good base.
393 Now open the Project Properties dialog and add "Comctl32.lib" and all the FLTK
394 libraries that you want to use (at least "fltk.lib") to Additional Dependencies
395 (Configuration Properties > Linker > Additional Dependencies). In the same
396 dialog, add "WIN32" to the C++ Preprocessor Definitions (Configuration
397 Properties > C/C++ > Preprocessor > Preprocessor Definitions).
399 Compile and run your test program with F5.
401 You can also include .fl resources: add a new Header file to your project, but
402 let the name end in .fl. Right-click and select "Open with...". Add "fluid.exe"
403 from the "bin" directory and set it as the default editor.
405 To automatically compile .fl files, open the Properties editor and set the
406 Custom Build Steps to:
408 Command Line: fluid.exe -c $(InputPath)
409 Description: Compiling Fluid .fl file
410 Outputs: $(InputDir)$(InputName).cxx; $(InputDir)$(InputName).h
412 Now add the generated .cxx file to your project as well. Whenever the .fl file
413 is changed, the corresponding .cxx file will be recompiled.
417 HOW TO BUILD FLTK USING VISUAL STUDIO 2010
418 ============================================
424 In order to build FLTK from within VisualStudio 2010, you need to install the
425 VisualC developer environment from the Microsoft web site. The Express edition
426 is free of charge and sufficient to develop FLTK applications:
428 http://www.microsoft.com/express/Downloads/
431 Downloading and Unpacking
432 ---------------------------
434 Download FLTK from here:
436 http://www.fltk.org/software.php
438 If you are familiar with "subversion" and like to stay current with your
439 version, you will find the subversion access parameters at the bottom of
442 Unpack FLTK by using an appropriate unpacker and copy the new folder into a
443 convenient location. I have set up a "dev" folder in my home folder for all
450 Launch VisualStudio. Open the project file in
452 .../fltk-1.3.xxxx/ide/VisualC2010/fltk.sln
454 Choose "Debug" or "Release" mode from the "Solution Configurations" menu.
460 Use the context menu of the "demo" project to "Set as StartUp Project". Then
461 select "Build Solution" from the "Build" menu or press F7 to build all
468 Select "Start Debugging" from the "Debug" menu or just press F5 to run the
469 Demo program. Use "Demo" to explore all test programs.
475 The default location for VisualC 2010 libraries and headers is here:
477 C:\Program Files\Microsoft Visual Studio 10.0\VC\
479 It is possible to move the FLTK libraries, headers, and Fluid into the
480 respective subdirectories, so that they are available for future development
481 without adding link and include paths to the solution.
483 copy the entire FL directory into the include path
485 copy all .lib files from the fltk lib directory to the VC lib directory
487 copy fluid.exe in the fluid directory to the bin directory
489 I highly discourage using dll's (dynamically linking libraries) on MSWindows
490 because they will require an installation process and likely cause version
491 conflicts. Use the static .lib libraries instead.
494 Creating new Projects
495 -----------------------
497 This chapter assumes that libraries and headers are copied into
499 C:\Program Files\Microsoft Visual Studio 10.0\VC\
501 Create a new project of type "General", "Empty Project" and add a simple "C++"
502 file to it. The FLTK "hello" source code is a good base.
504 Now open the Project Properties dialog and add "Comctl32.lib" and all the FLTK
505 libraries that you want to use (at least "fltk.lib") to Additional Dependencies
506 (Configuration Properties > Linker > Additional Dependencies). In the same
507 dialog, add "WIN32" to the C++ Preprocessor Definitions (Configuration
508 Properties > C/C++ > Preprocessor > Preprocessor Definitions).
510 Compile and run your test program with F5.
512 You can also include .fl resources: add a new Header file to your project, but
513 let the name end in .fl. Right-click and select "Open with...". Add "fluid.exe"
514 from the "bin" directory and set it as the default editor.
516 To automatically compile .fl files, open the Properties editor and change the
517 Element Type to Custom Build and click Apply. Now set the
518 Custom Build Steps to:
520 Command Line: fluid.exe -c %(FullPath)
521 Description: Compiling Fluid .fl file
522 Outputs: $(InputDir)$(InputName).cxx; $(InputDir)$(InputName).h
524 Now add the generated .cxx file to your project as well. Whenever the .fl file
525 is changed, the corresponding .cxx file will be recompiled.
529 FREQUENTLY ASKED QUESTIONS
530 ============================
533 Why does a console window appear when I run my program?
534 ---------------------------------------------------------
536 Windows has a flag that determines whether an application
537 runs in the foreground with a console or in the background
538 without a console. Use the "-mwindows" option to make your
539 application run in the background and "-mconsole" to run in
542 Keep in mind that a windows application cannot send output
543 to stdout, even if you run it from an existing console
545 (Note: A special case of this exists if running a MinGW
546 application from the command line of an MSYS shell, when an
547 application is able to write to stdout, even if compiled with
548 "-mwindows". The same applies to Cygwin.)
551 How do I get OpenGL to work?
552 ------------------------------
554 Both builds should automatically support OpenGL.
556 The configuration file config.h has a number of settings
557 which control compile-time compilation. One such setting is
558 "HAVE_GL". This may be set to 0 to disable Open GL operation.
559 Changing the line in config.h to
563 will change this to compile and link in OpenGL.
570 The following links may be of use:
572 1. Main Cygwin homepage:
574 http://www.cygwin.com/
576 2. Main Mingw homepage:
578 http://www.mingw.org/
580 In particular look for the MinGW FAQ at this link for
581 a lot of useful Mingw-native development
585 3. Check out the FLTK newsgroups at the FLTK homepage:
589 Its archival search facilities are EXTREMELY useful
590 to check back through previous problems with this
591 sort of configuration before posting new questions.
593 4. GNU Compiler Collection (GCC) compiler homepage:
597 5. OpenGL page - for OpenGL and GLUT libs
599 http://www.opengl.org/
606 Oct 25 2010 - matt: restructured entire document and verified instructions
607 Dec 20 2010 - matt: merged with README.win32
608 Dec 22 2010 - AlbrechtS: added newer Cygwin (cross/mingw-w64) options