You are here

Got Ubuntu. Got Gimp. Want to code a C plugin. What's next?

It's been about a decade since I've done significant work on a *nix machine, but I've installed Ubuntu primarily with the purpose in mind of developing Gimp plugins, and I'm eager to get started. So, now what?

How do I set up a dev environment and pull down (or point to) the necessary libs and source files? Could somebody walk me through from a fresh new environment to compiling a "Hello, Filter!"?

It seems like it should be incredibly simple, because every FAQ or tutorial that I find online seems to assume that I've made it past the "insert code here" phase and am actually wrestling with real problems.


I started to code gimp plugins just lately – and Im not programmer. Some time ago I learned C++ (or rather made a small program for personal use in C++) and now I started my two gimp plugins.

First – Do you know about this tutorial? :
I started with this...

You did not mention what are you experiences with programming...

As for „dev environment“ - my dev environment is Geany – it is just text editor with syntax highlighting and a console where I run gimptool-2.0 command (this compiles the code). Very simple, but it works...

Third element of my dev environement is gimp. I mean gimp run from console – this way you can see errors (like gtk+ errors) or you can for debugging use printf in your plugin – I use it quite extensively... (One small detail I learned, you just dont need to restart gimp every time you recompile your plugin... might sound trivial, but I had to learn it)

Overall, I think there are not a lot and good tutorials for making gimp plugins, I was even considering writing my own....

I've been programming for a long time, though like I said, not on a *nix machine for about a decade now.

I'm probably spoiled, having spent the last few years doing C# in MS DevStudio. I'm no longer used to *nix conventions and also no longer used to arranging all the libs and directories by hand. Thus, I'm looking for a very detailed low-level procedure outline for what to download, what and where to install, where to put new code or how to point new code to the existing libs, and possibly an example compile command for gcc or somesuch just to illustrate take-off.

I basically want every step between installing Ubuntu and the first step listed at . If I had one of you guys sit next to me for twenty minutes, I'd probably be flying.

I'm also taking care of a six-week old, so I may not have the focused chunks of time it would take me to sort this stuff out without some hand-holding. This fact may be more relevant than my programming history, as it's taken me about 2 hours just to type this reply.

Thanks again!

no, no, no...
no "arranging all the libs and directories by hand". Nothing like this.

Only thing that can be little complicated for you is making sure that gimptool-2.0 is installed. It might be part of gimp package, then it already is installed, or it is separate package and you have to install it. Via package manager!

Than you need to create separate directory f.e.


there you will have file myplugin.c. Compilation is done with command:

gimptool-2.0 --install myplugin.c

this is done from console and you must be in that directory.
That is all, after this gimp will recognize newly created binary file. (it is automatically placed in ~/gimp-2.6/plug-ins/)

Ask what is not clear for you.

That's exactly what I needed to know. Thanks! It's always so nice to ask for help and find helpful people. I really appreciate this.

Now it seems I'm missing some env variables. I ran against a modified version of whirl-pinch.c by running:

gimptool-2.0 --install whirl-pinch.c

...and got this:

~/dev/gimp/whirl-pinch$ gimptool-2.0 --install whirl-pinch.c
gcc -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gimp-2.0 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pixman-1 -o /home/eldrich/.gimp-2.6/plug-ins/whirl-pinch whirl-pinch.c -pthread -L/usr/lib/x86_64-linux-gnu -lgimpui-2.0 -lgimpwidgets-2.0 -lgimpmodule-2.0 -lgimp-2.0 -lgimpmath-2.0 -lgimpconfig-2.0 -lgimpcolor-2.0 -lgimpbase-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lm -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
whirl-pinch.c:48:20: fatal error: config.h: No such file or directory
compilation terminated.

Is there a gcc or gimptool configure that needs to be run in order to set things up correctly? I think I could get it to run with additional gimptool options, but I'd rather fix the env than have to do that every time or alias in a bunch of clunky args.

no variables. It is header file config.h. It seams somewhere on the top of your .c file there is '#include config.h', and it seems that it is a file that belong to whirl-pinch and you had to put it into your working directory, but it is not there. Of course, it is a guess only, you must look into your .c file and find relevant line to see...

The whirl-pinch.c file references a number of headers, all of which are existing files in the GIMP source, and are not part of the plugin. They are:

#include "config.h"
#include "libgimp/stdplugins-intl.h"

It doesn't seem to know where to look for them, which makes me wonder if my source is installed correctly. How did you grab your source? I'm afraid I just downloaded and unzipped mine, so there's no way for the compiler to implicitly know where to look for the includes.

There's also a chance that I'm having this problem because I grabbed a plug-in from the default included set, and they're compiled slightly differently than externally included plug-ins. A from-scratch plug-in might not need the explicit includes.

I'll fiddle with things a bit. Thanks again, though.

I found this at

Incidentally, the difference between the two forms of the include statement #include "FILE.h" and #include <FILE.h> is that the former searches for ‘FILE.h’ in the current directory before looking in the system header file directories. The include statement #include <FILE.h> searches the system header files, but does not look in the current directory by default.

(Current comment system strips some characters, so your lines with includes were damaged, it seems.

It is sufficient to make source of plugin as a single file, but author might decide to split the file and create also header file. Make sure you read Readme and Install files (if any) in your source tarball.


I'm aware of the difference between referencing files from local directories versus common dev directories. I'm just not familiar with what needs to be done to add the gimp dev directories to the shared libraries. For now, I'm just moving my code into the root gimp source directory prior to running gimptool, and that's working. If I can fix it later, I will, but if not, this will at least let me start coding.

Thanks for the assist! Hopefully I'll have something nifty to post to the plugin registry soon!

Did you try the template? (a hollow shell of a C plugin for GIMP.) The purpose of the template is to provide a canonical build environment.

I haven't used it in a while. It might be a good starting point, that doesn't require any futzing with env variables and libraries. It does use the GNU build system (automake, configure, etc.) which can be daunting.

So basically:

install (say using Synaptic) the gimp-dev package to get the gimp development libraries (and the gimp build tool?)

download plug-in-template and unarchive it to a new directory

cd to that directory

> ./configure

> make

> make install

Then hack the template and remake.

Don't use the existing gimp plugins included with the gimp distribution source as a starting point for your own plugins, as they are written up to be compiled along with the gimp source tree and have dependencies that would NOT be included when using gimptool.

A great example is "libgimp/stdplugins-intl.h". I was told on the dev list a 3rd part plugin should never include this, instead it should provide its own i18n headers as required.

-Rob A>

Subscribe to Comments for "Got Ubuntu. Got Gimp. Want to code a C plugin. What&#039;s next?"