FLTK in VS2010

HOW TO BUILD FLTK USING VISUAL STUDIO 2010
============================================


Prerequisites
---------------

In order to build FLTK from within VisualStudio 2010, you need to install the
VisualC developer environment from the Microsoft web site. The Express edition
is free of charge and sufficient to develop FLTK applications:

  http://www.microsoft.com/express/Downloads/


Downloading and Unpacking
---------------------------

Download FLTK from here:

  http://www.fltk.org/software.php

If you are familiar with "subversion" and like to stay current with your
version, you will find the subversion access parameters at the bottom of
that page.

Unpack FLTK by using an appropriate unpacker and copy the new folder into a
convenient location. I have set up a "dev" folder in my home folder for all
my projects.


Configuring FLTK
------------------

Launch VisualStudio. Open the project file in

  .../fltk-1.3.xxxx/ide/VisualC2010/fltk.sln

Choose "Debug" or "Release" mode from the "Solution Configurations" menu.(all build)


Building FLTK
---------------

Use the context menu of the "demo" project to "Set as StartUp Project". Then
select "Build Solution" from the "Build" menu or press F7 to build all
libraries.


Testing FLTK
--------------

Select "Start Debugging" from the "Debug" menu or just press F5 to run the
Demo program. Use "Demo" to explore all test programs.


Installing FLTK
-----------------

The default location for VisualC 2010 libraries and headers is here:

  C:\Program Files\Microsoft Visual Studio 10.0\VC\

It is possible to move the FLTK libraries, headers, and Fluid into the
respective subdirectories, so that they are available for future development
without adding link and include paths to the solution.

  copy the entire FL directory into the include path

  copy all .lib files from the fltk lib directory to the VC lib directory

  copy fluid.exe in the fluid directory to the bin directory

I highly discourage using dll's (dynamically linking libraries) on MSWindows
because they will require an installation process and likely cause version
conflicts. Use the static .lib libraries instead.


Creating new Projects
-----------------------

This chapter assumes that libraries and headers are copied into

  C:\Program Files\Microsoft Visual Studio 10.0\VC\

Create a new project of type "General", "Empty Project" and add a simple "C++"
file to it. The FLTK "hello" source code is a good base.

Now open the Project Properties dialog and add "Comctl32.lib" and all the FLTK
libraries that you want to use (at least "fltk.lib"(debug mode using fltkd.lib, release mode using fltk.lib)) to Additional Dependencies
(Configuration Properties > Linker > Additional Dependencies). In the same
dialog, add "WIN32" to the C++ Preprocessor Definitions (Configuration
Properties > C/C++ > Preprocessor > Preprocessor Definitions).

Compile and run your test program with F5.

You can also include .fl resources: add a new Header file to your project, but
let the name end in .fl. Right-click and select "Open with...". Add "fluid.exe"
from the "bin" directory and set it as the default editor.

To automatically compile .fl files, open the Properties editor and change the
Element Type to Custom Build and click Apply. Now set the
Custom Build Steps to:

  Command Line: fluid.exe -c %(FullPath)
  Description: Compiling Fluid .fl file
  Outputs: $(InputDir)$(InputName).cxx; $(InputDir)$(InputName).h

Now add the generated .cxx file to your project as well. Whenever the .fl file
is changed, the corresponding .cxx file will be recompiled.

posted on 2012-08-22 15:16  fire_fuxm_USTC  阅读(891)  评论(0编辑  收藏  举报