Hi,
GIMP is compiling ok, next step was to compile a plugin. Please bear in mind my understanding is
as deep as a puddle. Any pointers appreciated!
#include <libgimp/gimp.h>
static void query(void);
static void run(const gchar *name, gint nparams, const GimpParam *param,
gint *nreturn_vals, GimpParam **return_vals);
GimpPlugInInfo PLUG_IN_INFO = {
NULL, // init_proc
NULL, // quit_proc
query, // query_proc
run // run_proc
};
MAIN()
static void query(void) {
static GimpParamDef args[] = {
{
GIMP_PDB_INT32, // type
"run-mode", // name
"Run mode" // description
}
};
gimp_install_procedure(
"plug-in-hello", // name
"Hello", // blurb
"Displays a 'Hello' message", // help
"Your Name", // author
"Your Copyright", // copyright
"2023", // date
"<Image>/Filters/Hello", // menupath
"", // imagetypes
GIMP_PLUGIN, // type
G_N_ELEMENTS(args), // nparams
0, // nreturn_vals
args // params
);
}
static void run(const gchar *name, gint nparams, const GimpParam *param,
gint *nreturn_vals, GimpParam **return_vals) {
g_message("Hello!");
*nreturn_vals = 0;
*return_vals = NULL;
}
This is the contents of a âCMakeLists.txtâ file, for some reason I had to add some include directories. Which I thought PkgConfig was for?
cmake_minimum_required(VERSION 3.0)
project(gimp-compiled-plugins)
set(CMAKE_C_STANDARD 11)
include_directories(
${GIMP_INCLUDE_DIRS}
/home/mark/Code/gimp-source/include/gimp-3.0/libgimp;
/usr/include/cairo;
/home/mark/Code/gimp-source/build/glib/glib;
/home/mark/Code/gimp-source/build/glib/gobject
)
find_package(PkgConfig REQUIRED)
# Set the PKG_CONFIG_PATH environment variable
set(ENV{PKG_CONFIG_PATH}
"/home/mark/Code/gimp-source/lib/x86_64-linux-gnu/pkgconfig \
:$ENV{PKG_CONFIG_PATH}")
pkg_check_modules(GIMP REQUIRED gimp-3.0)
pkg_check_modules(GIMP REQUIRED gimp-3.0)
link_directories(${GIMP_LIBRARY_DIRS})
add_definitions(${GIMP_CFLAGS_OTHER})
add_executable(hello-world hello-world/src/main.c)
target_link_libraries(hello-world ${GIMP_LIBRARIES})
~/Code/gimp-plugin/gimp-compiled-plugins/build$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mark/Code/gimp-plugin/gimp-compiled-plugins/build
Make result:
~/Code/gimp-plugin/gimp-compiled-plugins/build$ make
Consolidate compiler generated dependencies of target hello-world
[ 50%] Building C object CMakeFiles/hello-world.dir/hello-world/src/main.c.o
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:4:56: error: unknown type name âGimpParamâ
4 | static void run(const gchar *name, gint nparams, const GimpParam *param,
| ^~~~~~~~~
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:5:37: error: unknown type name âGimpParamâ; did you mean âGimpArrayâ?
5 | gint *nreturn_vals, GimpParam **return_vals);
| ^~~~~~~~~
| GimpArray
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:7:1: error: unknown type name âGimpPlugInInfoâ; did you mean âGimpPlugInâ?
7 | GimpPlugInInfo PLUG_IN_INFO = {
| ^~~~~~~~~~~~~~
| GimpPlugIn
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:8:3: warning: initialization of âintâ from âvoid *â makes integer from pointer without a cast [-Wint-conversion]
8 | NULL, // init_proc
| ^~~~
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:8:3: note: (near initialization for âPLUG_IN_INFOâ)
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:9:3: warning: excess elements in scalar initializer
9 | NULL, // quit_proc
| ^~~~
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:9:3: note: (near initialization for âPLUG_IN_INFOâ)
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:10:3: warning: excess elements in scalar initializer
10 | query, // query_proc
| ^~~~~
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:10:3: note: (near initialization for âPLUG_IN_INFOâ)
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:11:3: error: ârunâ undeclared here (not in a function); did you mean âtruncâ?
11 | run // run_proc
| ^~~
| trunc
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:11:3: warning: excess elements in scalar initializer
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:11:3: note: (near initialization for âPLUG_IN_INFOâ)
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:14:1: warning: return type defaults to âintâ [-Wimplicit-int]
14 | MAIN()
| ^~~~
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c: In function âMAINâ:
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:16:25: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â{â token
16 | static void query(void) {
| ^
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:41:56: error: unknown type name âGimpParamâ
41 | static void run(const gchar *name, gint nparams, const GimpParam *param,
| ^~~~~~~~~
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:42:37: error: unknown type name âGimpParamâ; did you mean âGimpArrayâ?
42 | gint *nreturn_vals, GimpParam **return_vals) {
| ^~~~~~~~~
| GimpArray
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:48: error: expected â{â at end of input
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c: At top level:
/home/mark/Code/gimp-plugin/gimp-compiled-plugins/hello-world/src/main.c:3:13: warning: âqueryâ used but never defined
3 | static void query(void);
| ^~~~~
make[2]: *** [CMakeFiles/hello-world.dir/build.make:76: CMakeFiles/hello-world.dir/hello-world/src/main.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/hello-world.dir/all] Error 2
make: *** [Makefile:91: all] Error 2