Looking to implement a drawing canvas in C/C++ and, after failing to make code from the internet work, I came across this sample code which does exactly what I need. The code compiles with the terminal command provided by Martin:
gcc example.c -o example `pkg-config --cflags --libs gtk+-3.0`
In Codeblocks, I've started a new GTK+ Project, added the sample code in it and I get
error: unkown type name 'GtkApplication'
Please advise how to set up CodeBlocks. I've tried tinkering with the Compiler Options in CodeBlocks without any luck.
Follow-up:
I checked which packages I have installed and it seems I have both GTK2 and GTK3.
I've pasted the output of the "command flags" ...
pkg-config --cflags --libs gtk+-3.0
in CodeBlocks -> Project -> Build Options -> Other compiler options. The previous errors are gone, but new errors are raised:
undefined reference to 'gtk_widget_get_allocated_width'
undefined reference to 'gtk_widget_get_allocated_height'
undefined reference to 'gtk_application_window_new'
undefined reference to 'gtk_application_get_type'
undefined reference to 'gtk_window_set_application'
undefined reference to 'gtk_box_new'
undefined reference to 'gtk_application_new'
The motivation behind all this is to use a debugger (I am not able to work with text-based gdb).
Many thanks, Dani
pkg-config .....
only works from the command line. You need to run that command on the command line (without the back ticks (`) and then use the output to adjust the compiler settings in codeblocks. Alternatively, you could just use a text editor to edit the code and continue to compile on the command line. The number of questions dealing with codeblocks on this site leads me to think that it is not worth the effort to learn. – thurizas