ImageGear for C and C++ on Linux v19.10 - Updated
Compiling and Linking
User Guide > How to Work with... > Create an Imaging Application > Compiling and Linking

Linux-based applications that call ImageGear functions may be compiled using any ANSI C or C++ compiler, though some compilers’ switch settings may be slightly different from those shown in the examples below.

To compile and link your program:

  1. Inform the compiler where to find the standard and ImageGear “#include” files.
  2. Inform the linker where to find the ImageGear library.
  3. Inform the linker which libraries to use.

To inform the compiler of the path to your “#include” files, use the -I switch. If gear.h is in $HOME/Accusoft/ImageGearXX-64/include directory, use the following specification:

 
Copy Code

-I$HOME/Accusoft/ImageGearXX-64/include

Use a switch such as -L to direct the linker to the ImageGear library file, using:

 
Copy Code

-L$HOME/Accusoft/ImageGearXX-64/bin/

Use a switch such as -l to instruct the linker to the libraries to be included in the link process. You must include the ImageGear library:

 
Copy Code

-lIGCOREXX

Toolkit Libraries

You may need to include toolkit libraries using:

 
Copy Code

-lXm -lXt

X-Windows System and Math Library

In addition to linking with libIGCOREXX.a, you must also link with the X Windows System library (libX11.a) when building GUI applications, the math library (libm.a), and the thread support library (libpthread). These libraries should be in the following order:

 
Copy Code

-lIGCOREXX -lX11 -lm -lpthread

Depending on the platform, the dynamic loader may also be required:

 
Copy Code

-lIGCOREXX -lX11 -lm -lpthread –ldl

Compilation Flags

You must also define certain flags compiler. Most, if not all, will be included by the preprocessor, but you may find it necessary to define them yourself. They are:

 
Copy Code

-D_UNIX64 (all 64-bit platforms)
-D__unix (all platforms)
-D__linux (Linux)

The compile/link will build your application’s executable file. If you link to the shared ImageGear library, the path to that library must be included in the library path environment variable, such as LD_LIBRARY_PATH. That directs the system to the shared library files.

Build Samples

Starting with ImageGear for C and C++ v18.1, all supplied samples use the CMake build system. Given that CMake is installed and available, invoke:

 
Copy Code

cmake <path to CMakeLists.txt>

from the build directory to generate Makefile. Then invoke:

 
Copy Code

make

to actually build the sample.