<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../Xsl/doc2html.xsl"?>
<doc>
  <title>Install and Compile</title>
  <chapter>
    <title>Install and Compile</title>
    <par>
      Simply extract contents of distributed archive somewhere
      on your hard disk and Imaging is installed.
      However, you need to setup your compilers to be able to compile
      Imaging.
    </par>
  
    <table>
      <title>Source directories needed to be known by compilers</title>
      <row>
        <th>Directory</th>
        <th>Contents</th>
      </row>
      <row>
        <td><keyword>(Imaging Root)\Source</keyword></td>
        <td>Imaging library source code</td>
      </row>
      <row>
        <td><keyword>(Imaging Root)\Source\JpegLib</keyword></td>
        <td>JpegLib needed by Imaging to load/save JPEG/JNG images</td>
      </row>
      <row>
        <td><keyword>(Imaging Root)\Source\ZLib</keyword></td>
        <td>ZLib needed by Imaging to decode/decode PNG/MNG image data and other things</td>
      </row>
      <row>
        <td><keyword>(Imaging Root)\Source\Projects</keyword></td>
        <td>Project files for libraries and packages</td>
      </row>
      <row>
        <td><keyword>(Imaging Root)\Source\Extensions</keyword></td>
        <td>Imaging extensions source code</td>
      </row>
      <row>
        <td><keyword>(Imaging Root)\Source\Wrappers\*</keyword></td>
        <td>Wrappers for other languages</td>
      </row>
      <row>
        <td><keyword>(Imaging Root)\Demos\ObjectPascal\Common</keyword></td>
        <td>Some common routines used by Object Pascal demos</td>
      </row>
      <row>
        <td><keyword>(Imaging Root)\Extras\Extensions</keyword></td>
        <td>Extras extensions source code (mainly new file formats)</td>
      </row>
      <row>
        <td><keyword>(Imaging Root)\Extras\Extensions\J2KObjects</keyword></td>
        <td>Dir with static libraries needed for FPC if you have
          JPEG 2000 support enabled. Must be added to FPC library path (-Fl).</td>
      </row>
      <row>
        <td><keyword>(Imaging Root)\Extras\Extensions\LibTiff</keyword></td>
        <td>Needed for <link url="../FileFormats/Tiff.xml">TIFF</link> support in Delphi.</td>
      </row>
    </table>

    <lcap>Compiler Setup</lcap>
    
    <mcap>Compiling Library</mcap>
    
    <scap>Delphi/Kylix Setup</scap>
    <par>
      You need to add directories listed in the above
      table to library path.
    </par>
    <olist>
      <li>Choose <mitem>Tools<inimg url="../../Common/path.png" />Options<inimg
      url="../../Common/path.png" />Environment Options<inimg
      url="../../Common/path.png" />Delphi Options<inimg
      url="../../Common/path.png" />Library - Win32</mitem>
      in Delphi 2005+ or <mitem>Tools<inimg
      url="../../Common/path.png" />Environment Options<inimg
      url="../../Common/path.png" />Library</mitem> in Delphi 7- and Kylix.
      </li>
      <li>Add directories to <mitem>Library path</mitem> string.</li>
    </olist>

    <scap>Free Pascal Setup</scap>
    <par>
      You can write settings to <keyword>fpc.cfg</keyword> configuration
      file or use them directly as command line parameters
    </par>
    <olist>
      <li>
        Use <keyword>-FuUnitPath</keyword> parameter for all
        directories listed in the above table and <keyword>-FiIncludePath</keyword>
        only for <keyword>(Imaging_Root)\Source</keyword> directory.
        Also library path must me added for JPEG2000
        (Imaging Root\Extras\Extensions\J2KObjects) using <keyword>-FlLibPath</keyword>.
        Example: <keyword>fpc -FuD:\Imaging\Source -FuD:\Imaging\Source\JpegLib ... -FiD:\Imaging\Source</keyword>
      </li>
      <li>
        You should also set compiler mode and other compilation specific options.
        I use <keyword>-Sgi2dh</keyword> and it works.
        <keyword>g</keyword> means allow <icode>goto</icode>,
        <keyword>i</keyword> means allow function inlining,
        <keyword>2</keyword> allows some Delphi 2 extensions,
        <keyword>d</keyword> turns on Delphi compatibility mode
        and <keyword>h</keyword> turns on ANSI strings.
      </li>
    </olist>
    
    <mcap>Using Wrappers For Other Languages</mcap>
    <scap>Delphi.NET Setup</scap>
    <par>
      You need to add directory in which Delphi.NET wrapper is located
      to library path.
    </par>
    <olist>
    <li>Choose <mitem>Tools<inimg url="../../Common/path.png" />Options<inimg
      url="../../Common/path.png" />Environment Options<inimg
      url="../../Common/path.png" />Delphi Options<inimg
      url="../../Common/path.png" />Library - NET</mitem>
      in Delphi 2005+.</li>
      <li>Add directory to <mitem>Library path</mitem> string.</li>
    </olist>
    
    <scap>C/C++ Compiler Setup</scap>
    <par>
      Settings depend entirely on the compiler used.
      You need to add directory in which C/C++ wrapper headers are located
      to its include path and then compile <icode>ImagingImport.c</icode>
      file located in wrapper directory and link it with your object files.
      You can find working MS VC++ 8.0 project in <keyword>Demos\Cpp\Bench</keyword>
      directory.
    </par>

    <lcap>Build Scripts</lcap>
    <par>
      You can also compile Imaging library and demos without
      setting your compilers. All you need is to make sure that you have
      paths to compilers' executables in your system's search path
      (<keyword>PATH</keyword> environment variable).
      Then you can run one of these scripts located in <keyword>Scripts</keyword>
      directory:
    </par>

    <table>
      <row>
        <th>Script Name</th>
        <th>Usage</th>
      </row>
      <row>
        <td><keyword>BuildLibraryDelphi.bat (Win32)</keyword></td>
        <td>Builds <keyword>VampyreImaging.dll</keyword> in
        <keyword>Bin</keyword> directory using Delphi</td>
      </row>
      <row>
        <td><keyword>BuildLibraryFPC.bat (Win32)</keyword></td>
        <td>Builds <keyword>VampyreImaging.dll</keyword> in
        <keyword>Bin</keyword> directory using Free Pascal</td>
      </row>
      <row>
        <td><keyword>BuildLibraryFPC.sh (Linux/Unix)</keyword></td>
        <td>Builds <keyword>libVampyreImaging.so</keyword> in
        <keyword>Bin</keyword> directory using Free Pascal</td>
      </row>
      <row>
        <td><keyword>BuildDemosDelphi.bat (Win32)</keyword></td>
        <td>Builds demos in <keyword>Demos\Bin</keyword> directory using Delphi</td>
      </row>
      <row>
        <td><keyword>BuildExtDemosDelphi.bat (Win32)</keyword></td>
        <td>Builds demos of Imaging extensions which require external units
        in <keyword>Demos\Bin</keyword>
        directory using Delphi (<link url="#extnote">Note</link>)</td>
      </row>
      <row>
        <td><keyword>BuildDemosFPC.bat (Win32)</keyword></td>
        <td>Builds demos in <keyword>Demos\Bin</keyword> directory using Free Pascal</td>
      </row>
      <row>
        <td><keyword>BuildDemosFPC64.bat (Win64)</keyword></td>
        <td>Builds demos in <keyword>Demos\Bin</keyword> directory using Free Pascal</td>
      </row>
      <row>
        <td><keyword>BuildExtDemosFPC.bat (Win32)</keyword></td>
        <td>Builds demos of Imaging extensions which require external units
        in <keyword>Demos\Bin</keyword>
        directory using Free Pascal (<link url="#extnote">Note</link>)</td>
      </row>
      <row>
        <td><keyword>BuildDemosDOS.bat (DOS)</keyword></td>
        <td>Builds demos in <keyword>Demos\Bin</keyword> directory using Free Pascal</td>
      </row>
      <row>
        <td><keyword>BuildDemosFPC.sh (Linux/Unix)</keyword></td>
        <td>Builds demos in <keyword>Demos/Bin</keyword> directory using Free Pascal</td>
      </row>
      <row>
        <td><keyword>BuildExtDemosFPC.sh (Linux/Unix)</keyword></td>
        <td>Builds demos of Imaging extensions which require external units
        in <keyword>Demos\Bin</keyword>
        directory using Free Pascal (<link url="#extnote">Note</link>)</td>
      </row>
    </table>
    
    <anchor name="extnote">
      <note>
        You must first set search directories in which
        third party units required by some demos (like <keyword>JEDI-SDL</keyword>,
        <keyword>Direct3D</keyword>, ...) are located. Just open the script and
        you will see couple of empty variables (like <icode>set SDLDIR=</icode> in
        *.bat or <icode>SDLDIR=""</icode> in *.sh script). Set the variables
        to paths to required libraries and run the script. If you don't have
        some of these libraries installed and variables are left empty
        demos which require them will be simply skipped when the script is
        executed.
      </note>
    </anchor>

  </chapter>
</doc>
