Setting up GIMP SDK
Depending on the language you plan to create a resource for GIMP, using GIMP SDK may be useful. This allows to quickly build resources like C plug-ins and C GEGL filters, for example, without bothering too much about technical things like linking etc.
Getting the SDK
We ship GIMP SDK inside all the official/upstream packages we distribute.
It is composed by pkg-config files, unversioned libraries and headers pertinent to our main API libraries, so it is very lightweight and portable.
GIMP SDK dependencies
The only thing you need to install is the toolchain (compiler and pkg-config), all the rest needed to link to the API libraries is already on the official packages.
Installing GIMP dependencies will automatically install both the compiler and pkg-config but also other dependencies not needed by the API libraries, which can be useful if your resource needs the later.
Configuring the environment
The build environment variables needed to build with GIMP SDK are the same as for
building GIMP, being mainly PATH (to
gimptool find the compiler and pkg-config).
Optionally, if you want to find gimptool on PATH too, you can set GIMP_PREFIX:
- Linux .APPIMAGE: not on PATH, it is called with
GIMP*.AppImage --gimptool - Windows .EXE: normally
$GIMP_PREFIX="$(Resolve-Path "$env:LocalAppData\Programs\GIMP*")"(system-wide .exe and .msix may not work since they are on %ProgramFiles%, which contains spaces unsupported by pkg-config) - macOS .DMG: normally
GIMP_PREFIX="$(echo /Applications/GIMP*.app/Contents)"
After GIMP_PREFIX is set, don’t forget to set PATH.
Building the resource with GIMP SDK
Once the SDK is properly set as per instructions above, you are ready to build.
Simple building
Please keep an eye at How to write a plug-in and
How to write a filter tutorials when gimptool is requested.
It will just work.
That tool will also display the full compiler flags used to build the plug-in or filter.
Build system
Rather than always compiling manually with gimptool, you may be interested to write a build script so that you can easily recompile your plug-in or filter, without having to remember compiler options and typing long command lines.
These days, we mostly suggest to use the meson build
system.
For instance, this very basic meson.build file installed in the same
directoy as the C sources will compile one plug-in appropriately:
project('c-hello-world', 'c', version : '0.1')
gimp = dependency('gimp-3.0', required : true)
compiler_args = []
linker_args = []
if host_machine.system().to_lower().contains('darwin')
#macosx_deployment_target = 'LSMinimumSystemVersion value from Info.plist of target /Applications/GIMP.app'
compiler_args += ['-mmacos-version-min=' + macosx_deployment_target]
linker_args += ['-mmacos-version-min=' + macosx_deployment_target]
#needed by build_rpath and install_rpath
linker_args += ['-Wl,-headerpad_max_install_names']
endif
executable('c-hello-world',
'c-hello-world.c',
dependencies: [ gimp ],
c_args: compiler_args,
link_args: linker_args,
win_subsystem: 'windows',
build_rpath: '/Applications/GIMP.app/Contents/lib',
install_rpath: '/Applications/GIMP.app/Contents/lib',
install: true)This sample meson.build will compile two GEGL filters/operations
appropriately:
project('gimp-tutorial-point-filter-op', 'c', version : '0.1')
gegl = dependency('gegl-0.4', required : true)
compiler_args = []
linker_args = []
if host_machine.system().to_lower().contains('darwin')
#macosx_deployment_target = 'LSMinimumSystemVersion value from Info.plist of target /Applications/GIMP.app'
compiler_args += ['-mmacos-version-min=' + macosx_deployment_target]
linker_args += ['-mmacos-version-min=' + macosx_deployment_target]
#needed by build_rpath and install_rpath
linker_args += ['-Wl,-headerpad_max_install_names']
endif
if not host_machine.system().to_lower().contains('windows')
compiler_args += ['-fpic']
endif
op1 = shared_module('gimp-tutorial-meta-op',
'gimp-tutorial-meta-op.c',
dependencies : [gegl],
name_prefix : '',
c_args: compiler_args,
link_args: linker_args,
build_rpath: '/Applications/GIMP.app/Contents/lib',
install_rpath: '/Applications/GIMP.app/Contents/lib',
install: true)
op2 = shared_module('gimp-tutorial-point-filter-op',
'gimp-tutorial-point-filter-op.c',
dependencies : [gegl],
name_prefix : '',
c_args: compiler_args,
link_args: linker_args,
build_rpath: '/Applications/GIMP.app/Contents/lib',
install_rpath: '/Applications/GIMP.app/Contents/lib',
install: true)Now what you have to do is to compile using the same commands
as for building GIMP. Once compiled, you will find the binary files in
your _build/ directory.