On 13/11/2007, Aurimas Juška wrote:
I think it would be very useful if you could tell us how to compile
using both Microsoft Visual Studio and msys/mingw32.
Well, in a nutshell, you have to know what you are doing;) Short instructions:
Most importantly, the plug-in obviously must not use some POSIX-only
or Linux-only APIs that are not available in the C library on Windows.
You will need the header files for GIMP and the ones they include
(GTK+ and its dependencies), and import libraries for the DLLs that
the plug-in uses. (If you don't know what an import library is, look
in the interweb.)
As far as I know there is no distribution of a GIMP 2.4 developer
package for Windows, unfortunately. But I think it should work fine to
use headers and import libraries from GIMP 2.2, so get
http://www.gimp.org/~tml/gimp/win32/gimp-dev-2.2.7.zip .
(I will shortly create a developer package for GIMP 2.4 and add a link
to it on the http://www.gimp.org/~tml/gimp/win32/downloads.html page.)
Unzip the developer package in some suitably named new, empty folder.
You will also need developer packages for GTK+, Pango, atk and glib.
Unzip them, too, in either the same, or separate folders.
With Visual Studio: set up a project that compiles the plug-in's
source file(s), and pass the correct -I flags to the compiler so that
it finds the header files, and the correct /libpath switches to the
linker so that it finds the import libraries, and link with the
correct libraries (the same ones you link with on Linux).
With MSYS: Basically do like on Linux. If you are using auto* and
libtool on Linux (as you should), but have never used those on Windows
before, it can be a pain to set them up. So maybe for a small, perhaps
just a single source file, program like a GIMP plug-in you shouldn't
bother. Just write a makefile from scratch that builds your plug-in.
One thing you need to watch out for is the correct order of object (or
source) files and -L and -l options on the command line. The
non-traditional order allowed by gcc and ld on Linux don't work for ld
on Win32.
To find out what the correct compiler and linker flags are, you can
use the gimptool-2.0.exe program distributed with the gimp developer
package. It requires that you also have the pkg-config program
(available from the downloads.html web page mentioned above) and the
PKG_CONFIG_PATH environment variable correctly set up, so if that
causes a headache to you, it might be easier to just write the
makefile from scratch.
You can use gimptool-2.0.exe also to find out the flags for the
Microsoft compiler and linker. Just pass the --msvc-syntax flag to
gimptool-2.0.exe. (But see above about pkg-config and
PKG_CONFIG_PATH.)
So, in a nutshell, this is not rocket science. It's simply a matter of
invoking the compiler with the right flags. I suggest staying away
from tools like dev-cpp that try to make things easier but only
succeed in preventing you from learning how things actually work.
Dev-cpp etc might be fine for Your First Hello World program, but once
you get past that, you need to get your fingers dirty. Feel free to
disagree, of course.
--tml