Raspberry Pi - Geany and GTK - C/ C++ With: #include

by Novellus in Circuits > Raspberry Pi

162 Views, 0 Favorites, 0 Comments

Raspberry Pi - Geany and GTK - C/ C++ With: #include

Geany_Lamp_01.jpg
GTK_01.jpg
Raspberry_Pi_01.jpg

This Instructables provides guidance on overcoming the Geany "Compilation Failure" errors on a Raspberry Pi when the Geany IDE is used to compile or build C / C++ files that contain the following pre-processor command:

# include < gtk/gtk.h >

This Instructable assumes the following:

  • Your Raspberry Pi OS is up-to date.
  • Geany was installed in the "Programming:" section on the Raspberry Pi.
  • You've properly installed GTK per their instructions.
    • This could be a variant of version 2.0 or version 3.0

I'm also providing a link to my YouTube video on this very subject matter.

Supplies

Raspberry Pi - the more modern the better.. but I use a 3b - and it's good to go.

Geany IDE (included FREE with latest versions of Raspberry Pi OS)

GTK Software (For Linux) - Free from GTK Site (link).

== == ==

A YouTube video of this Instructables (link)

== == ==

The Problem:

Compilation_Error_01.jpg

On a fresh installation of Geany, when trying to "Build" or "Compile" a C or C++ file that contains the pre-processor command: #include the compiler reports a fatal error and compiler failure.

gtk/gtk.h: No such file or directory.

The issue relates to Geany and the compiler not being able to find the necessary files.

Lets fix that next.

For C Language Programs.

For "C" programming:

1st - Load a "C" type of file (.c type extension).

In my case, I created a very simple file named ==> geany_gtk_setup.c

next..

In the "Build" then "Set Build Command".

Expand the window to see everything.

There you'll see the top three entries under a heading "C Commands":

C commands entry #1 is named "Compile", and should contain the following:

gcc -Wall -c "%f"

Add the following text to it (be sure to include the "single quote marks":

`pkg-config --cflags gtk+-3.0`
-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_0

End result is to be like:

gcc -Wall -c "%f" `pkg-config --cflags gtk+-3.0`
DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_0

finally..

C commands entry #2 is named "Build", and should contain the following:

gcc -Wall -o "%e" "%f"

Add the following text to it (be sure to include the "single quote marks":

`pkg-config --cflags gtk+-3.0`
-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_0 `pkg-config --libs gtk+-3.0`

End result is to be like:

gcc -Wall -o "%e" "%f“`pkg-config --cflags gtk+-3.0`
-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_0 `pkg-config --libs gtk+-3.0`

For C++ Language Programs.

For "C++" programming:

1st - Load a "C++" type of file (.cpp type extension).

In my case, I created a very simple file named ==> geany_gtk_setup.cpp

next..

In the "Build" then "Set Build Command".

Expand the window to see everything.

There you'll see the top three entries under a heading "C++ Commands":

C++ commands entry #1 is named "Compile", and should contain the following:

g++
-Wall -c "%f"

Add the following text to it (be sure to include the "single quote marks":

`pkg-config --cflags gtk+-3.0`
-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_0

End result is to be like:

g++ -Wall -c "%f" `pkg-config --cflags gtk+-3.0` DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_0

finally..

C++ commands entry #2 is named "Build", and should contain the following:

g++ -Wall -o "%e" "%f"

Add the following text to it (be sure to include the "single quote marks":

`pkg-config --cflags gtk+-3.0`
-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_0 `pkg-config --libs gtk+-3.0`

End result is to be like:

g++ -Wall -o "%e" "%f“ `pkg-config --cflags gtk+-3.0` -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_0 `pkg-config --libs gtk+-3.0`

Test Program - C - Geany_gtk_test.c

//

// ***********************************************

//

// September 24-2020

//

// Code written on a Raspberry Pi 3B, using Geany v1.33.

//

// Notes: Test GTK Set-up in Geany with C

//

// ***********************************************

//

#include <gtk/gtk.h>

void set_DAC01()

{

printf("Will #include actually work in C ?");

}

Test Program - C++ - Geany_gtk_test.cpp

//

// ***********************************************

//

// September 24-2020

//

// Code written on a Raspberry Pi 3B, using Geany v1.33.

//

// Notes: Test GTK Set-up in Geany with C++

//

// ***********************************************

//

#include <gtk/gtk.h>

void set_DAC01()

{

printf("Will #include actually work in C++ ?");

}

Detailed PDF Presentation of This Process.

Attached is a PDF Document on how to proceed at your own pace.