a:2:{i:0;s:9:"(unknown)";i:1;s:0:"";}
This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
a:2:{i:0;s:9:"(unknown)";i:1;s:0:"";} | Yavala | 31 Oct 08:23 |
a:2:{i:0;s:9:"(unknown)";i:1;s:0:"";} | Tor Lillqvist | 31 Oct 11:07 |
a:2:{i:0;s:9:"(unknown)";i:1;s:0:"";}
Can someone help me with the simple plug-in (hello message box)http://developer.gimp.org/writing-a-plug-in/1/index.html? I have also included the Hello.c source code. I encountered the following error.
Compiler: Default compiler
Building Makefile: "E:\Makefile.win"
Executing make...
make.exe -f "E:\Makefile.win" SimplePlugin/hello.o
gcc.exe -c SimplePlugin/hello.c -o SimplePlugin/hello.o -I"E:/Dev-Cpp/include"
-ansi -traditional-cpp -w -fmessage-length=0
SimplePlugin/hello.c:6: error: syntax error before string constant SimplePlugin/hello.c:27: error: syntax error before string constant SimplePlugin/hello.c:39: error: syntax error before '*' token SimplePlugin/hello.c: In function `run': SimplePlugin/hello.c:45: error: syntax error before "values"
SimplePlugin/hello.c:46: error: `GimpPDBStatusType' undeclared (first use in
this function)
SimplePlugin/hello.c:46: error: (Each undeclared identifier is reported only
once
SimplePlugin/hello.c:46: error: for each function it appears in.)
SimplePlugin/hello.c:47: error: `GimpRunMode' undeclared (first use in this
function)
SimplePlugin/hello.c:50: error: `nreturn_vals' undeclared (first use in this
function)
SimplePlugin/hello.c:51: error: `return_vals' undeclared (first use in this
function)
SimplePlugin/hello.c:51: error: `values' undeclared (first use in this function)
SimplePlugin/hello.c:53: error: `GIMP_PDB_STATUS' undeclared (first use in this
function)
SimplePlugin/hello.c:54: error: `status' undeclared (first use in this function)
SimplePlugin/hello.c:58: error: `run_mode' undeclared (first use in this
function)
SimplePlugin/hello.c:58: error: `param' undeclared (first use in this function)
SimplePlugin/hello.c:60: error: `GIMP_RUN_NONINTERACTIVE' undeclared (first use
in this function)
make.exe: *** [SimplePlugin/hello.o] Error 1
Execution terminated
Source Code For hello.c
include "libgimp/gimp.h"
static void query (void)
{
static GimpParamDef args[] = {
{
GIMP_PDB_INT32,
"run_mode",
"Run mode"
},
{
GIMP_PDB_IMAGE,
"image",
"Input image"
},
{
GIMP_PDB_DRAWABLE,
"drawable",
"Input drawable"
}
};
gimp_install_procedure (
"plug_in_hello",
"Hello, world!",
"Displays \"Hello, world!\" in a dialog",
"David Neary",
"Copyright David Neary",
"2004",
"/Filters/Misc/_Hello world...",
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
}
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpRunMode run_mode;
/* Setting mandatory output values */
*nreturn_vals = 1;
*return_vals = values;
values[0].type = GIMP_PDB_STATUS; values[0].data.d_status = status; /* Getting run_mode - we won't display a dialog if * we are in NONINTERACTIVE mode */ run_mode = param[0].data.d_int32; if (run_mode != GIMP_RUN_NONINTERACTIVE)g_message("Hello, world!\n"); }
a:2:{i:0;s:9:"(unknown)";i:1;s:0:"";}
Yavala writes:
> Can someone help me with the simple plug-in (hello message
> box)http://developer.gimp.org/writing-a-plug-in/1/index.html?
Well, the most obvious error is that there is no initial '#' character on the line where you try to include libgimp/gimp.h. (Have you never programmed in C before?) It should look like this:
#include "libgimp/gimp.h"
You also need to have the PLUG_IN_INFO array and MAIN(). Add the following to the bottom of the source file:
GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
MAIN ()
The menu path to the plug-in that is passed to gimp_install_procedure() needs to start with . Change it as follows:
gimp_install_procedure (
"plug_in_hello",
"Hello, world!",
"Displays \"Hello, world!\" in a dialog",
"David Neary",
"Copyright David Neary",
"2004",
"/Filters/Misc/Hello world...",
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
}
With these changes your plug-in compiles and works fine with GIMP 2.2.
--tml