Building from Source - GreycLab/gmic-community GitHub Wiki

Makefile

The source distributions include a Makefile for GNU Make. The standard targets are:

  • gmic command line
  • gimp_gmic plug-in
  • gmic link-library, linux only provided as standard
  • zart requires X11 type display

... in addition "gmic_minimal" is a useful target, for example:

  • gmicol the on-line version of the gmic command-line is limited to float-type data and doesn't require displays etc.

There is no configure step, make itself detects the host type amongst: Linux / OS X (Darwin) / Windows (MINGW32_NT).

Linux Source Packages for G'MIC GIMP plugin

Most likely you are better off using your package manager to obtain the correct dependencies for your system.

Gentoo (media-plugins/gimp-gmic) http://packages.gentoo.org/package/media-plugins/gimp-gmic e.g. gimp-gmic-1.5.6.1.ebuild (04 Jul 2013) by Tim Harder (radhermit)

FreeBSD (graphics/gimp-gmic-plugin) http://www.freshports.org/graphics/gimp-gmic-plugin/ e.g. 1.5.5.2 "upgrade to 1.5.6" (04 Jul 2013) by thierry

RedHat/Fedora/CentOS/OpenSUSE (Fedora 17 / RPM Sphere x86_64‎) https://build.opensuse.org/package/binaries/home:zhonghuaren/gmic?repository=Fedora_18 e.g. gmic-1.5.5.2-4.1.src.rpm (02 Jun 2013) by zhonghuaren

Built-in GMIC script commands

Each compiled distribution includes the corresponding gmic_def within the executable itself.

The file "gmic_def.h" is generated from "gmic_def.gmic" (see Makefile target "def:") which ensures the standard commands compatible with that release are available.

Note that built-in functions require a signature or function prototype declaration so that the parser correctly scans the arguments.

G'MIC Command Line Tool

The standard build includes multiple data-types for the CImg template library. Split-compilation of the same source code with different data types is necessary to avoid excessive memory and time for the optimising compiler; this is because it searches for potential shared-code between templates. For many purposes the minimal, floating point version would suffice.

Recommended libraries:

  • cimg_use_fftw3 , requires fftw3 , enables fast-fourier transform
  • cimg_use_jpeg , requires libjpeg , enables loading/saving jpeg
  • cimg_use_png , requires libpng , enables portable network graphics
  • cimg_use_zlib , requires zlib , enables zip deflate needed for cimgz

Other optional libraries:

  • cimg_use_opencv, requires OpenCV , gmic uses it only for a compatible webcam
  • cimg_use_xshm, requires Xext, shared memory extension for X Windows
  • cimg_use_minc2, requires Medical Imaging suite around ".mnc" format volumetric data
  • cimg_use_ffmpeg, requires ffmpeg library enables native loading and saving of 2d image lists as movie frames
  • cimg_use_tiff , requires libtiff , enables tiff format
  • cimg_use_magick, requires the Magick++ library, enables Graphics Magic native calls as opposed to externally
  • cimg_use_openexr, requires IlmImf and Half libraries, enables RAW images in ".exr" files.
  • cimg_use_board, CImg requires 'board' a Vector Graphics library to draw and export .svg .eps files, don't think this is accessible from gmic anyway

MSYS / MinGW (Minimalist GNU on Windows)

This is a bare-bones GCC tool-chain for creating windows 32-bit executables.

Static doesn't affect treatment of DLLs 3.15Mb: gcc -Wall -Wfatal-errors -Wl,-s -Os -Wl,-Bstatic -Dcimg_OS=2 -Dgmic_build gmic.cpp -Dgmic_float_only -Dgmic_main -lgdi32 -lstdc++ -o gmic.exe

Cygwin - Posix Emulation on Windows

The environment of cygwin makes windows look similar to *nix. The supplied Makefile will set cimg_OS=1 and require X11 which is probably not what you want. Cygwin headers require sources need editing to remove the leading underscore from _snprintf _getpid _setmode _fileno.

To compile without make use: g++ -Wl,-s -Os -o gmic gmic.cpp -DHAVE_BOOLEAN -Dcimg_use_jpeg -Dcimg_OS=2 -Dgmic_build -Dgmic_float_only -Dgmic_main -lgdi32 -ljpeg The -DHAVE_BOOLEAN tells the jpeg header not to redefine boolean.

additional flags -Dcimg_use_fftw3 -Dcimg_use_png -Dcimg_use_zlib -lfftw3 -lz -lpng gives dependency on cygfftw3-3.dll , cygpng15-15.dll , cygz.dll

This creates a 3.1Mb 32-bit exe which is dynamically linked and depends on: cygwin1.dll, cygjpeg-8.dll, cyggcc_s-1.dll, cygstdc++-6.dll as well as standard Windows DLLs : GDI32.dll, KERNEL32.dll, SHELL32.DLL, USER32.dll

G'MIC under Cygwin will give warnings about windows style "" path separators and will fail on paths containing ":".

Compiling to Windows 64bit

MinGW-w64 provides a 32-bit toolchain (build=i686-pc-mingw32) that produces standalone 64-bit executables (host=x86_64-w64-mingw32) named x86_64-w64-mingw32-g++

Cygwin can install cross-compiler tool-chain for x86_64-w64-mingw32 which will enable the "-b" option. g++ -b x86_64-w64-mingw32

In either case you need to ensure headers and link libraries for 64-bit are in the relevant architecture specific directories. e.g. MinGW-w64 : /lib/gcc/x86_64-w64-mingw32/4.8.0/include Cygwin : /usr/lib/gcc/x86_64-w64-mingw32/4.5.3/include

MS Visual C++ 2010

The project file type must target a Console Application and define gmic_main etc. as above.

The compiler requires explicit casting doubles to float for the calls to constructors.

G'MIC GIMP plug-in

This plug-in has to register function pointers to "gmic_query" and "gmic_run" in GIMP's procedural database, it also defines the plug-in's user-interface with GTK+ widgets.

The Makefile build assumes you have the gimptool utility in your the system path.

The gmic library used is identical except defining "gmic_gimp" during build includes relevant gimp headers in the custom commands compiled into the executable ( char data_gmic_def[] in gmic_def.h ).

G'MIC on-line

This is simply a version of the command line with option "cimg_display=0".

Make gmicol

It targets gmic_minimal which handles only the 'float' data-type and includes basic libraries.

You may also want to use switches 'gmic_noexec' which removes just the -x built-in command and 'cimg_no_system_calls' that neutralises many other calls to cimg::system( for external programs.

G'MIC Library

The gmic library exposes its command line parser allowing your apps to embed its processing and script functionality, see the minimal example:

gmic_use_lib.cpp