Blame README.MSWindows.txt

Packit 328d5c
README.MSWindows.txt - 2016-10-16 - Building FLTK under Microsoft Windows
Packit 328d5c
-------------------------------------------------------------------------
Packit 328d5c
Packit 328d5c
Packit 328d5c
Packit 328d5c
 CONTENTS
Packit 328d5c
==========
Packit 328d5c
Packit 328d5c
  1   INTRODUCTION
Packit 328d5c
  2   HOW TO BUILD FLTK USING MinGW/Cygwin
Packit 328d5c
    2.1   The Tools
Packit 328d5c
    2.2   Recommended Command Line Build Environment
Packit 328d5c
    2.3   Prerequisites
Packit 328d5c
    2.4   Downloading and Unpacking
Packit 328d5c
    2.5   Configuring FLTK
Packit 328d5c
    2.6   Building FLTK
Packit 328d5c
    2.7   Testing FLTK
Packit 328d5c
    2.8   Installing FLTK
Packit 328d5c
    2.9   Creating new Projects
Packit 328d5c
  3   HOW TO BUILD FLTK USING VISUAL STUDIO 2008
Packit 328d5c
    3.1   Prerequisites
Packit 328d5c
    3.2   Downloading and Unpacking
Packit 328d5c
    3.3   Configuring FLTK
Packit 328d5c
    3.4   Building FLTK
Packit 328d5c
    3.5   Testing FLTK
Packit 328d5c
    3.6   Installing FLTK
Packit 328d5c
    3.7   Creating new Projects
Packit 328d5c
  4   HOW TO BUILD FLTK USING VISUAL STUDIO 2010 OR LATER
Packit 328d5c
    4.1   Prerequisites
Packit 328d5c
    4.2   Downloading and Unpacking
Packit 328d5c
    4.3   Configuring FLTK
Packit 328d5c
    4.4   Building FLTK
Packit 328d5c
    4.5   Testing FLTK
Packit 328d5c
    4.6   Installing FLTK
Packit 328d5c
    4.7   Creating new Projects
Packit 328d5c
  5   FREQUENTLY ASKED QUESTIONS
Packit 328d5c
  7   LINKS
Packit 328d5c
  6   DOCUMENT HISTORY
Packit 328d5c
Packit 328d5c
Packit 328d5c
 INTRODUCTION
Packit 328d5c
==============
Packit 328d5c
Packit 328d5c
FLTK 1.3 and later is officially supported on Windows (2000,) 2003,
Packit 328d5c
XP, and later.  Older Windows versions are not officially supported,
Packit 328d5c
but may still work.  The main reason is that the OS version needs
Packit 328d5c
to support UTF-8. FLTK 1.3 is known to work on Windows Vista, Windows 7,
Packit 328d5c
Windows 8/8.1, and Windows 10.
Packit 328d5c
Packit 328d5c
FLTK currently supports the following development
Packit 328d5c
environments on the Windows platform:
Packit 328d5c
Packit 328d5c
    - Free Microsoft Visual C++ 2008 Express and Visual C++ 2010 Express
Packit 328d5c
      using the supplied workspace and project files. Older and the
Packit 328d5c
      commercial versions can be used as well, if they can open the project
Packit 328d5c
      files. Visual C++ 2015 Express/Community can be used with the
Packit 328d5c
      Visual C++ 2010 project files. Be sure to get your service packs!
Packit 328d5c
Packit 328d5c
      The project files can be found in the ide/ directory.
Packit 328d5c
      Please read ide/README.IDE for more info about this.
Packit 328d5c
Packit 328d5c
    - GNU toolsets (Cygwin or MinGW) hosted on Windows.
Packit 328d5c
Packit 328d5c
CAUTION: Libraries built by any one of these environments can not be mixed
Packit 328d5c
with object files from any other environment!
Packit 328d5c
Packit 328d5c
Packit 328d5c
 HOW TO BUILD FLTK USING MinGW and Cygwin
Packit 328d5c
==========================================
Packit 328d5c
Packit 328d5c
This chapter of this document gives a brief overview of
Packit 328d5c
compiling and using FLTK with the Cygwin and MinGW compiler
Packit 328d5c
toolkits.  Both toolkits provide a build environment based
Packit 328d5c
around the GNU C/C++ compiler. Further information is
Packit 328d5c
available from the FLTK website at http://www.fltk.org, such
Packit 328d5c
as this Howto note: http://www.fltk.org/articles.php?L598
Packit 328d5c
Packit 328d5c
The Cygwin build environment supplies a library (the Cygwin
Packit 328d5c
DLL) that is primarily intended to provide a number of
Packit 328d5c
Unix-like POSIX facilities for programs being ported to the
Packit 328d5c
Windows environment (Win32 or WinNT).  Cygwin also supplies
Packit 328d5c
a very Unix-like build environment for Windows, including
Packit 328d5c
the "BASH" Bourne-compatible shell and all of the standard
Packit 328d5c
Unix file utilities (ls, cat, grep, etc.).
Packit 328d5c
Packit 328d5c
Cygwin is developed by Cygnus (now part of RedHat, Inc).
Packit 328d5c
Although provided for free download under the GPL,
Packit 328d5c
distributing programs that require the Cygwin DLL under a
Packit 328d5c
license other than the GPL requires a commercial license for
Packit 328d5c
the Cygwin DLL.  Native Windows programs that do not require
Packit 328d5c
the Cygwin DLL (compiled and linked with the "-mno-cygwin"
Packit 328d5c
option) may be released under any license freely.
Packit 328d5c
Packit 328d5c
Note: Since December 2009, there is a new gcc 4.x compiler
Packit 328d5c
that doesn't support the -mno-cygwin option anymore. You
Packit 328d5c
must use the older gcc-3 compiler instead.
Packit 328d5c
Packit 328d5c
An alternative is to install the new (since about Oct. 2010)
Packit 328d5c
mingw cross tools that support newer gcc compilers for building
Packit 328d5c
native Windows applications (like -mno-cygwin above).
Packit 328d5c
Currently you would have to install mingw64-i686-gcc-g++ for
Packit 328d5c
32-bit Windows applications (despite its name!), and/or
Packit 328d5c
mingw64-x86_64-gcc-g++ for 64-bit applications. You may also
Packit 328d5c
need to install the corresponding '-headers' packages as well.
Packit 328d5c
Currently these tools support gcc 4.5.x or newer, but the
Packit 328d5c
setup for FLTK is somewhat more complicated and not yet
Packit 328d5c
completely supported automatically (you may need to edit
Packit 328d5c
some lines in the generated makeinclude file).
Packit 328d5c
Packit 328d5c
The MinGW distribution (Minimalist GNU for Windows) provides
Packit 328d5c
a similar toolset but geared solely towards native Windows
Packit 328d5c
development without the Unix-like POSIX library.  The lack of
Packit 328d5c
any libraries under the GPL or any other restrictive license
Packit 328d5c
means that programs built with the MinGW environment may
Packit 328d5c
always be released under any license freely. MinGW also
Packit 328d5c
supplies a Unix-like build environment for Windows,
Packit 328d5c
including MSYS (a Bourne-compatible shell) and the standard
Packit 328d5c
Unix file utilities (ls, cat, grep, etc.)
Packit 328d5c
Packit 328d5c
If you are not familiar with these GNU-like toolkits please
Packit 328d5c
refer to the links section later in this note. In particular,
Packit 328d5c
check out their license conditions carefully before use.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 The Tools
Packit 328d5c
-----------
Packit 328d5c
Packit 328d5c
There are currently three main configurations supported by
Packit 328d5c
FLTK with the GNU tools:
Packit 328d5c
Packit 328d5c
    1. Cygwin: Built using the Cygwin toolset and using the
Packit 328d5c
       Unix-like POSIX compatibility layer provided by the
Packit 328d5c
       Cygwin DLL.
Packit 328d5c
Packit 328d5c
    2. Cygwin using the "-mno-cygwin" option: Built using
Packit 328d5c
       the Cygwin toolset but not using the Cygwin DLL.
Packit 328d5c
Packit 328d5c
    3. MinGW: Built using the MinGW utilities, compiler and
Packit 328d5c
       tools. This is, in many aspects, analogous to the
Packit 328d5c
       Cygwin "-mno-cygwin" option. This is the recommended
Packit 328d5c
       one if you want to build native Windows programs only.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Recommended Command Line Build Environment
Packit 328d5c
--------------------------------------------
Packit 328d5c
Packit 328d5c
Our recommendation is to:
Packit 328d5c
Packit 328d5c
    1. Get the current Cygwin toolset.
Packit 328d5c
Packit 328d5c
       This can either produce executables that do or do not
Packit 328d5c
       rely on the Cygwin DLL (check licensing) at your
Packit 328d5c
       choice.
Packit 328d5c
Packit 328d5c
    2. Get the latest MinGW toolset. It is recommended that
Packit 328d5c
       you also get the MSYS shell and the msysDTK developer
Packit 328d5c
       toolset.
Packit 328d5c
Packit 328d5c
       This will only produce normal Windows native
Packit 328d5c
       executables without any Unix or POSIX compatibility
Packit 328d5c
       layer.
Packit 328d5c
Packit 328d5c
Packit 328d5c
       See the links section below for more information.
Packit 328d5c
Packit 328d5c
Either option can generate windows-native executables and
Packit 328d5c
option 1 can provide a Unix-like POSIX portability layer that
Packit 328d5c
is reliant on a GPLed library.
Packit 328d5c
Packit 328d5c
See the later sections for detailed information about using
Packit 328d5c
one of these configurations.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Prerequisites
Packit 328d5c
---------------
Packit 328d5c
Packit 328d5c
In order to build FLTK from the command line, you need to install the MinGW
Packit 328d5c
environment from www.mingw.org. The graphical installer "mingw-get-inst" can
Packit 328d5c
be downloaded here for free:
Packit 328d5c
Packit 328d5c
  http://www.mingw.org/wiki/Getting_Started
Packit 328d5c
Packit 328d5c
Launch the installer and follow the instructions. In the "Select Components"
Packit 328d5c
dialog, add "C++ Compiler", "MSYS Basic System", and "MinGW Developer Toolkit".
Packit 328d5c
Wait for the installer to finish.
Packit 328d5c
Packit 328d5c
After downloading and installing, you need to launch the MinGW Shell through
Packit 328d5c
the Start menu.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Downloading and Unpacking
Packit 328d5c
---------------------------
Packit 328d5c
Packit 328d5c
Download FLTK from here:
Packit 328d5c
Packit 328d5c
  http://www.fltk.org/software.php
Packit 328d5c
Packit 328d5c
into your home folder. The default location as seen from MSWindows is similar
Packit 328d5c
to
Packit 328d5c
Packit 328d5c
  C:\MinGW\msys\1.0\home\matt\
Packit 328d5c
Packit 328d5c
If you are familiar with "subversion" and like to stay current with your
Packit 328d5c
version, you will find the subversion access parameters at the bottom of
Packit 328d5c
that page. Unpack FLTK into a convenient location. I like to have everything
Packit 328d5c
in my dev directory:
Packit 328d5c
Packit 328d5c
  cd
Packit 328d5c
  mkdir dev
Packit 328d5c
  cd dev
Packit 328d5c
  tar xvfz fltk-1.3.xxxx.tar.gz
Packit 328d5c
  cd fltk-1.3.xxxx
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Configuring FLTK
Packit 328d5c
------------------
Packit 328d5c
Packit 328d5c
If you got FLTK via subversion then you need one extra step. Otherwise skip
Packit 328d5c
over this part. Stay in your FLTK source-code directory and type the
Packit 328d5c
following:
Packit 328d5c
Packit 328d5c
  NOCONFIGURE=1 ./autogen.sh
Packit 328d5c
Packit 328d5c
Now configure your FLTK installation:
Packit 328d5c
Packit 328d5c
  ./configure
Packit 328d5c
Packit 328d5c
ADVANCED: type "./configure --help" to get a complete list of optional
Packit 328d5c
configuration parameters. These should be pretty self-explanatory. Some
Packit 328d5c
more details can be found in README.
Packit 328d5c
:END_ADVANCED
Packit 328d5c
Packit 328d5c
The configuration script will check your machine for the required resources
Packit 328d5c
which should all have been part of your MinGW installation. Review the
Packit 328d5c
Configuration Summary, maybe take some notes.
Packit 328d5c
Packit 328d5c
ADVANCED: some versions of MinGW/Msys are broken and complain about a missing
Packit 328d5c
--enable-auto-import. The solution is to upgrade to the current release. If
Packit 328d5c
that is not possible, you can include the --enable-auto-import flag when
Packit 328d5c
linking:
Packit 328d5c
  ./configure <config flags> LDFLAGS=-Wl,--enable-auto-import
Packit 328d5c
:END_ADVANCED
Packit 328d5c
Packit 328d5c
Packit 328d5c
Known Problems:
Packit 328d5c
Packit 328d5c
  There is a known incompatibility with some Windows subversion tools that
Packit 328d5c
  may not set the correct line endings for autoconf. If you get strange
Packit 328d5c
  error messages when running ./configure or make, you may need to convert
Packit 328d5c
  configh.in to "Unix line endings" (LF-only). These error messages are
Packit 328d5c
  unspecific, e.g. compilation errors like:
Packit 328d5c
Packit 328d5c
     error: 'U32' does not name a type
Packit 328d5c
     error: 'bmibuffer' was not declared in this scope
Packit 328d5c
Packit 328d5c
  You can fix the line endings with the MinGW/msys tool 'unix2dos' (u2d)
Packit 328d5c
  or with your favorite editor, if it allows to change the line endings,
Packit 328d5c
  then run autoconf and ./configure again.
Packit 328d5c
  For further information see this bug report:
Packit 328d5c
     http://www.fltk.org/newsgroups.php?gfltk.bugs+v:10197
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Building FLTK
Packit 328d5c
---------------
Packit 328d5c
Packit 328d5c
Now this is easy. Stay in your FLTK source-code directory and type:
Packit 328d5c
Packit 328d5c
  make
Packit 328d5c
Packit 328d5c
The entire FLTK toolkit including many test programs will be built for you.
Packit 328d5c
No warnings should appear.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Testing FLTK
Packit 328d5c
--------------
Packit 328d5c
Packit 328d5c
After a successful build, you can test FLTK's capabilities:
Packit 328d5c
Packit 328d5c
  test/demo
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Installing FLTK
Packit 328d5c
-----------------
Packit 328d5c
Packit 328d5c
If you did not change any of the configuration settings, FLTK will be
Packit 328d5c
installed in "/usr/local/include" and "/usr/local/lib" by typing
Packit 328d5c
Packit 328d5c
  make install
Packit 328d5c
Packit 328d5c
It is possible to install FLTK in user space by changing the installation path
Packit 328d5c
to a location within the user account by adding the "--prefix=PREFIX" parameter
Packit 328d5c
to the "./configure" command.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Creating new Projects
Packit 328d5c
-----------------------
Packit 328d5c
Packit 328d5c
FLTK provides a neat script named "fltk-config" that can provide all the flags
Packit 328d5c
needed to build FLTK applications using the same flags that were used to build
Packit 328d5c
the library itself. Running "fltk-config" without arguments will print a list
Packit 328d5c
of options. The easiest call to compile an FLTK application from a single
Packit 328d5c
source file is:
Packit 328d5c
Packit 328d5c
  fltk-config --compile myProgram.cxx
Packit 328d5c
Packit 328d5c
"fltk-config" and "fluid" will be installed in "/usr/local/bin/" by default.
Packit 328d5c
I recommend that you add it to the command search path.
Packit 328d5c
Packit 328d5c
Packit 328d5c
Packit 328d5c
 HOW TO BUILD FLTK USING VISUAL STUDIO 2008
Packit 328d5c
============================================
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Prerequisites
Packit 328d5c
---------------
Packit 328d5c
Packit 328d5c
In order to build FLTK from within VisualStudio 2008, you need to install the
Packit 328d5c
VisualC developer environment from the Microsoft web site. The Express edition
Packit 328d5c
is free of charge and sufficient to develop FLTK applications:
Packit 328d5c
Packit 328d5c
  http://www.microsoft.com/express/Downloads/
Packit 328d5c
Packit 328d5c
You must make sure that at least VisualStudio 2008 Service Pack 1 is installed
Packit 328d5c
or building FLTK on a multicore CPU will be very painful!
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Downloading and Unpacking
Packit 328d5c
---------------------------
Packit 328d5c
Packit 328d5c
Download FLTK from here:
Packit 328d5c
Packit 328d5c
  http://www.fltk.org/software.php
Packit 328d5c
Packit 328d5c
If you are familiar with "subversion" and like to stay current with your
Packit 328d5c
version, you will find the subversion access parameters at the bottom of
Packit 328d5c
that page.
Packit 328d5c
Packit 328d5c
Unpack FLTK by using an appropriate unpacker and copy the new folder into a
Packit 328d5c
convenient location. I have set up a "dev" folder in my home folder for all
Packit 328d5c
my projects.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Configuring FLTK
Packit 328d5c
------------------
Packit 328d5c
Packit 328d5c
Launch VisualStudio. Open the project file in
Packit 328d5c
Packit 328d5c
  ...\fltk-1.3.xxxx\ide\VisualC2008\fltk.sln
Packit 328d5c
Packit 328d5c
Choose "Debug" or "Release" mode from the "Solution Configurations" menu.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Building FLTK
Packit 328d5c
---------------
Packit 328d5c
Packit 328d5c
Use the context menu of the "demo" project to "Set as StartUp Project". Then
Packit 328d5c
select "Build Solution" from the "Build" menu or press F7 to build all
Packit 328d5c
libraries.
Packit 328d5c
Packit 328d5c
VisualC 2008 has a bug that messes up building a Solution on multicore CPUs.
Packit 328d5c
Make sure that Visual Studio 2008 Service Pack 1 is installed or, as a
Packit 328d5c
workaround, set the "maximum number of parallel project builds" to 1 (Tools >
Packit 328d5c
Options > Projects and Solutions > Build and Run > maximum number of parallel
Packit 328d5c
project builds). Also, repeating the build command two or three times may
Packit 328d5c
clear unresolved reference errors.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Testing FLTK
Packit 328d5c
--------------
Packit 328d5c
Packit 328d5c
Select "Start Debugging" from the "Debug" menu or just press F5 to run the
Packit 328d5c
Demo program. Use "Demo" to explore all test programs.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Installing FLTK
Packit 328d5c
-----------------
Packit 328d5c
Packit 328d5c
The default location for VisualC 2008 libraries and headers is here:
Packit 328d5c
Packit 328d5c
  C:\Program Files\Microsoft Visual Studio 9.0\VC\
Packit 328d5c
Packit 328d5c
It is possible to move the FLTK libraries, headers, and Fluid into the
Packit 328d5c
respective subdirectories, so that they are available for future development
Packit 328d5c
without adding link and include paths to the solution.
Packit 328d5c
Packit 328d5c
  copy the entire FL directory into the include path
Packit 328d5c
Packit 328d5c
  add all files from ide\VisualC2008\FL to the FL directory copied above
Packit 328d5c
    (this is currently only one file: abi-version.h)
Packit 328d5c
Packit 328d5c
  copy all .lib files from the fltk lib directory to the VC lib directory
Packit 328d5c
Packit 328d5c
  copy fluid.exe in the fluid directory to the bin directory
Packit 328d5c
Packit 328d5c
I highly discourage using dll's (dynamically linking libraries) on MSWindows
Packit 328d5c
because they will require an installation process and likely cause version
Packit 328d5c
conflicts. Use the static .lib libraries instead.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Creating new Projects
Packit 328d5c
-----------------------
Packit 328d5c
Packit 328d5c
This chapter assumes that libraries and headers are copied into
Packit 328d5c
Packit 328d5c
  C:\Program Files\Microsoft Visual Studio 9.0\VC\
Packit 328d5c
Packit 328d5c
Create a new project of type "General", "Empty Project" and add a simple "C++"
Packit 328d5c
file to it. The FLTK "hello" source code is a good base.
Packit 328d5c
Packit 328d5c
Now open the Project Properties dialog and add "Comctl32.lib" and all the FLTK
Packit 328d5c
libraries that you want to use (at least "fltk.lib") to Additional Dependencies
Packit 328d5c
(Configuration Properties > Linker > Additional Dependencies). In the same
Packit 328d5c
dialog, add "WIN32" to the C++ Preprocessor Definitions (Configuration
Packit 328d5c
Properties > C/C++ > Preprocessor > Preprocessor Definitions).
Packit 328d5c
Packit 328d5c
Compile and run your test program with F5.
Packit 328d5c
Packit 328d5c
You can also include .fl resources: add a new Header file to your project, but
Packit 328d5c
let the name end in .fl. Right-click and select "Open with...". Add "fluid.exe"
Packit 328d5c
from the "bin" directory and set it as the default editor.
Packit 328d5c
Packit 328d5c
To automatically compile .fl files, open the Properties editor and set the
Packit 328d5c
Custom Build Steps to:
Packit 328d5c
Packit 328d5c
  Command Line: fluid.exe -c $(InputPath)
Packit 328d5c
  Description: Compiling Fluid .fl file
Packit 328d5c
  Outputs: $(InputDir)$(InputName).cxx; $(InputDir)$(InputName).h
Packit 328d5c
Packit 328d5c
Now add the generated .cxx file to your project as well. Whenever the .fl file
Packit 328d5c
is changed, the corresponding .cxx file will be recompiled.
Packit 328d5c
Packit 328d5c
Packit 328d5c
Packit 328d5c
 HOW TO BUILD FLTK USING VISUAL STUDIO 2010 OR LATER
Packit 328d5c
====================================================
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Prerequisites
Packit 328d5c
---------------
Packit 328d5c
Packit 328d5c
In order to build FLTK from within VisualStudio 2010 or later, you need to
Packit 328d5c
install the VisualC developer environment from the Microsoft web site. The
Packit 328d5c
Express edition is free of charge and sufficient to develop FLTK applications:
Packit 328d5c
Packit 328d5c
  http://www.microsoft.com/express/Downloads/
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Downloading and Unpacking
Packit 328d5c
---------------------------
Packit 328d5c
Packit 328d5c
Download FLTK from here:
Packit 328d5c
Packit 328d5c
  http://www.fltk.org/software.php
Packit 328d5c
Packit 328d5c
If you are familiar with "subversion" and like to stay current with your
Packit 328d5c
version, you will find the subversion access parameters at the bottom of
Packit 328d5c
that page.
Packit 328d5c
Packit 328d5c
Unpack FLTK by using an appropriate unpacker and copy the new folder into a
Packit 328d5c
convenient location. I have set up a "dev" folder in my home folder for all
Packit 328d5c
my projects.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Configuring FLTK
Packit 328d5c
------------------
Packit 328d5c
Packit 328d5c
Launch VisualStudio. Open the project file in
Packit 328d5c
Packit 328d5c
  .../fltk-1.3.xxxx/ide/VisualC2010/fltk.sln
Packit 328d5c
Packit 328d5c
Choose "Debug" or "Release" mode from the "Solution Configurations" menu.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Building FLTK
Packit 328d5c
---------------
Packit 328d5c
Packit 328d5c
Use the context menu of the "demo" project to "Set as StartUp Project". Then
Packit 328d5c
select "Build Solution" from the "Build" menu or press F7 to build all
Packit 328d5c
libraries.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Testing FLTK
Packit 328d5c
--------------
Packit 328d5c
Packit 328d5c
Select "Start Debugging" from the "Debug" menu or just press F5 to run the
Packit 328d5c
Demo program. Use "Demo" to explore all test programs.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Installing FLTK
Packit 328d5c
-----------------
Packit 328d5c
Packit 328d5c
The default location for VisualC 2010 libraries and headers is here:
Packit 328d5c
Packit 328d5c
  C:\Program Files\Microsoft Visual Studio 10.0\VC\
Packit 328d5c
Packit 328d5c
It is possible to move the FLTK libraries, headers, and Fluid into the
Packit 328d5c
respective subdirectories, so that they are available for future development
Packit 328d5c
without adding link and include paths to the solution.
Packit 328d5c
Packit 328d5c
  copy the entire FL directory into the include path
Packit 328d5c
Packit 328d5c
  add all files from ide\VisualC2010\FL to the FL directory copied above
Packit 328d5c
    (this is currently only one file: abi-version.h)
Packit 328d5c
Packit 328d5c
  copy all .lib files from the fltk lib directory to the VC lib directory
Packit 328d5c
Packit 328d5c
  copy fluid.exe in the fluid directory to the bin directory
Packit 328d5c
Packit 328d5c
I highly discourage using dll's (dynamically linking libraries) on MSWindows
Packit 328d5c
because they will require an installation process and likely cause version
Packit 328d5c
conflicts. Use the static .lib libraries instead.
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Creating new Projects
Packit 328d5c
-----------------------
Packit 328d5c
Packit 328d5c
This chapter assumes that libraries and headers are copied into
Packit 328d5c
Packit 328d5c
  C:\Program Files\Microsoft Visual Studio 10.0\VC\
Packit 328d5c
Packit 328d5c
Create a new project of type "General", "Empty Project" and add a simple "C++"
Packit 328d5c
file to it. The FLTK "hello" source code is a good base.
Packit 328d5c
Packit 328d5c
Now open the Project Properties dialog and add "Comctl32.lib" and all the FLTK
Packit 328d5c
libraries that you want to use (at least "fltk.lib") to Additional Dependencies
Packit 328d5c
(Configuration Properties > Linker > Additional Dependencies). In the same
Packit 328d5c
dialog, add "WIN32" to the C++ Preprocessor Definitions (Configuration
Packit 328d5c
Properties > C/C++ > Preprocessor > Preprocessor Definitions).
Packit 328d5c
Packit 328d5c
Compile and run your test program with F5.
Packit 328d5c
Packit 328d5c
You can also include .fl resources: add a new Header file to your project, but
Packit 328d5c
let the name end in .fl. Right-click and select "Open with...". Add "fluid.exe"
Packit 328d5c
from the "bin" directory and set it as the default editor.
Packit 328d5c
Packit 328d5c
To automatically compile .fl files, open the Properties editor and change the
Packit 328d5c
Element Type to Custom Build and click Apply. Now set the
Packit 328d5c
Custom Build Steps to:
Packit 328d5c
Packit 328d5c
  Command Line: fluid.exe -c %(FullPath)
Packit 328d5c
  Description: Compiling Fluid .fl file
Packit 328d5c
  Outputs: $(InputDir)$(InputName).cxx; $(InputDir)$(InputName).h
Packit 328d5c
Packit 328d5c
Now add the generated .cxx file to your project as well. Whenever the .fl file
Packit 328d5c
is changed, the corresponding .cxx file will be recompiled.
Packit 328d5c
Packit 328d5c
Packit 328d5c
Packit 328d5c
 FREQUENTLY ASKED QUESTIONS
Packit 328d5c
============================
Packit 328d5c
Packit 328d5c
Packit 328d5c
 Why does a console window appear when I run my program?
Packit 328d5c
---------------------------------------------------------
Packit 328d5c
Packit 328d5c
Windows has a flag that determines whether an application
Packit 328d5c
runs in the foreground with a console or in the background
Packit 328d5c
without a console.
Packit 328d5c
Packit 328d5c
If you're using gcc (i.e. MinGW or Cygwin), then use the
Packit 328d5c
linker option "-mwindows" to make your application run in
Packit 328d5c
the background and "-mconsole" to run in the foreground. Use
Packit 328d5c
fltk-config --ldflags to see appropriate linker flags, or use
Packit 328d5c
fltk-config --compile to compile a single source file.
Packit 328d5c
Packit 328d5c
If you're using MS VC++, then you must set the linker option
Packit 328d5c
"/subsystem:windows" to create a "Windows" program (w/o console
Packit 328d5c
window), or set the linker option "/subsystem:console" for a
Packit 328d5c
console program, i.e. with a console window. These options
Packit 328d5c
are set differently in the FLTK project files, depending on
Packit 328d5c
whether you select a "Debug" or "Release" build.
Packit 328d5c
Packit 328d5c
Other compilers and build systems may have different options.
Packit 328d5c
Packit 328d5c
Keep in mind that a windows application cannot send output
Packit 328d5c
to stdout, even if you run it from an existing console
Packit 328d5c
application.
Packit 328d5c
(Note: A special case of this exists if running a MinGW
Packit 328d5c
application from the command line of an MSYS shell, when an
Packit 328d5c
application is able to write to stdout, even if compiled with
Packit 328d5c
"-mwindows".  The same applies to Cygwin.)
Packit 328d5c
Packit 328d5c
Packit 328d5c
 How do I get OpenGL to work?
Packit 328d5c
------------------------------
Packit 328d5c
Packit 328d5c
Both builds should automatically support OpenGL.
Packit 328d5c
Packit 328d5c
The configuration file config.h has a number of settings
Packit 328d5c
which control compile-time compilation.  One such setting is
Packit 328d5c
"HAVE_GL". This may be set to 0 to disable Open GL operation.
Packit 328d5c
Changing the line in config.h to
Packit 328d5c
Packit 328d5c
    #define HAVE_GL 1
Packit 328d5c
Packit 328d5c
will change this to compile and link in OpenGL.
Packit 328d5c
Packit 328d5c
Packit 328d5c
Packit 328d5c
 LINKS
Packit 328d5c
=======
Packit 328d5c
Packit 328d5c
The following links may be of use:
Packit 328d5c
Packit 328d5c
1. Main Cygwin homepage:
Packit 328d5c
Packit 328d5c
       http://www.cygwin.com/
Packit 328d5c
Packit 328d5c
2. Main Mingw homepage:
Packit 328d5c
Packit 328d5c
       http://www.mingw.org/
Packit 328d5c
Packit 328d5c
   In particular look for the MinGW FAQ at this link for
Packit 328d5c
   a lot of useful Mingw-native development
Packit 328d5c
   documentation.
Packit 328d5c
Packit 328d5c
Packit 328d5c
3. Check out the FLTK newsgroups at the FLTK homepage:
Packit 328d5c
Packit 328d5c
       http://www.fltk.org/
Packit 328d5c
Packit 328d5c
   Its archival search facilities are EXTREMELY useful
Packit 328d5c
   to check back through previous problems with this
Packit 328d5c
   sort of configuration before posting new questions.
Packit 328d5c
Packit 328d5c
4. GNU Compiler Collection (GCC) compiler homepage:
Packit 328d5c
Packit 328d5c
       http://gcc.gnu.org/
Packit 328d5c
Packit 328d5c
5. OpenGL page - for OpenGL and GLUT libs
Packit 328d5c
Packit 328d5c
       http://www.opengl.org/
Packit 328d5c
Packit 328d5c
Packit 328d5c
Packit 328d5c
 DOCUMENT HISTORY
Packit 328d5c
==================
Packit 328d5c
Packit 328d5c
Oct 25 2010 - matt: restructured entire document and verified instructions
Packit 328d5c
Dec 20 2010 - matt: merged with README.win32
Packit 328d5c
Dec 22 2010 - AlbrechtS: added newer Cygwin (cross/mingw-w64) options
Packit 328d5c
Feb 24 2012 - AlbrechtS: clarified console window FAQ