# Install and Compile

# Install and Compile

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.

## Source directories needed to be known by compilers

Directory | Contents
--- | ---
(Imaging Root)\Source | Imaging library source code
(Imaging Root)\Source\JpegLib | JpegLib needed by Imaging to load/save JPEG/JNG images
(Imaging Root)\Source\ZLib | ZLib needed by Imaging to decode/decode PNG/MNG image data and other things
(Imaging Root)\Source\Projects | Project files for libraries and packages
(Imaging Root)\Source\Extensions | Imaging extensions source code
(Imaging Root)\Source\Wrappers\* | Wrappers for other languages
(Imaging Root)\Demos\ObjectPascal\Common | Some common routines used by Object Pascal demos
(Imaging Root)\Extras\Extensions | Extras extensions source code (mainly new file formats)
(Imaging Root)\Extras\Extensions\J2KObjects | Dir with static libraries needed for FPC if you have JPEG 2000 support enabled. Must be added to FPC library path (-Fl).
(Imaging Root)\Extras\Extensions\LibTiff | Needed for TIFF support in Delphi.

Compiler Setup
Compiling Library
Delphi/Kylix Setup
You need to add directories listed in the above table to library path.
- Choose ToolsOptionsEnvironment OptionsDelphi OptionsLibrary - Win32 in Delphi 2005+ or ToolsEnvironment OptionsLibrary in Delphi 7- and Kylix.
- Add directories to Library path string.
Free Pascal Setup
You can write settings to fpc.cfg configuration file or use them directly as command line parameters
- Use -FuUnitPath parameter for all directories listed in the above table and -FiIncludePath only for (Imaging_Root)\Source directory. Also library path must me added for JPEG2000 (Imaging Root\Extras\Extensions\J2KObjects) using -FlLibPath. Example: fpc -FuD:\Imaging\Source -FuD:\Imaging\Source\JpegLib ... -FiD:\Imaging\Source
- You should also set compiler mode and other compilation specific options. I use -Sgi2dh and it works. g means allow goto, i means allow function inlining, 2 allows some Delphi 2 extensions, d turns on Delphi compatibility mode and h turns on ANSI strings.
Using Wrappers For Other Languages
Delphi.NET Setup
You need to add directory in which Delphi.NET wrapper is located to library path.
- Choose ToolsOptionsEnvironment OptionsDelphi OptionsLibrary - NET in Delphi 2005+.
- Add directory to Library path string.
C/C++ Compiler Setup
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 ImagingImport.c file located in wrapper directory and link it with your object files. You can find working MS VC++ 8.0 project in Demos\Cpp\Bench directory.
Build Scripts
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 (PATH environment variable). Then you can run one of these scripts located in Scripts directory:

Script Name | Usage
--- | ---
BuildLibraryDelphi.bat (Win32) | Builds VampyreImaging.dll in Bin directory using Delphi
BuildLibraryFPC.bat (Win32) | Builds VampyreImaging.dll in Bin directory using Free Pascal
BuildLibraryFPC.sh (Linux/Unix) | Builds libVampyreImaging.so in Bin directory using Free Pascal
BuildDemosDelphi.bat (Win32) | Builds demos in Demos\Bin directory using Delphi
BuildExtDemosDelphi.bat (Win32) | Builds demos of Imaging extensions which require external units in Demos\Bin directory using Delphi (Note)
BuildDemosFPC.bat (Win32) | Builds demos in Demos\Bin directory using Free Pascal
BuildDemosFPC64.bat (Win64) | Builds demos in Demos\Bin directory using Free Pascal
BuildExtDemosFPC.bat (Win32) | Builds demos of Imaging extensions which require external units in Demos\Bin directory using Free Pascal (Note)
BuildDemosDOS.bat (DOS) | Builds demos in Demos\Bin directory using Free Pascal
BuildDemosFPC.sh (Linux/Unix) | Builds demos in Demos/Bin directory using Free Pascal
BuildExtDemosFPC.sh (Linux/Unix) | Builds demos of Imaging extensions which require external units in Demos\Bin directory using Free Pascal (Note)

You must first set search directories in which third party units required by some demos (like JEDI-SDL, Direct3D, ...) are located. Just open the script and you will see couple of empty variables (like set SDLDIR= in *.bat or SDLDIR="" 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.