Programing app Gtk in plasma using C VSCODE Compile errors

Hi
I am trying to write and compile a small program/function, which I hope to add to a program originally written in C. The original uses GTK so that’s what I am trying to write for my program which I will bolt in or call from within the original program, (its original function is not working). I will be using VSCode to write compile …

Enough on with the problem, its a file picker or is going to be using the “GtkWidget *dialog;”
I have three lines of code with the error on line 3

#include <gtk/gtk.h>

Error :
home/steve/Projects/FilePicker/bs-LoadPick
/home/steve/Projects/FilePicker/bs-LoadPick.cpp:3:10: fatal error: gtk/gtk.h: No such file or directory

I have tried google and youtube and had no joy working out what the problem is and how to fix it, does anyone know of a guide I can follow, on how to set up Arch based distro(EOS) for programming??
Been to arch forums and got my post deleted.

Will upload code source program to Pastebin or similar if required.

is GTK installed on your system?

Hi
It was one of the things I was thinking about, GTK is more gnome based,
I did however install(please see image)
123

I could be wrong.


Data

you need the GTK3 package and depending on what you want to do Glib2, but think you can do without.

sudo pacman -S gtk3

FileChoser1

ok, that’s not the problem.

What command are you compiling with?

Hi
I am using VSCode to run/debug/fix code.
I have setup up a Makefile as per one of the videos, I also setup
as per one of the videos, some compiler directives or similar I forget the
the exact definition given.

// gcc 007_gtk.c -o 007_gtk pkg-config --cflags gtk+-3.0 pkg-config --libs gtk+-3.0

The VSCode edit says do not pass go when I run debug.

check if pkgconf is installed.

pacman -Qs pkgconf

Hi Sorry @pycrk but is its showing as local, I reinstalled it all the same.

Data

put your code in pastebin, want to check it out.

Edit:
also check if the gtk.h file is present.
/usr/include/gtk-3.0/gtk/gtk.h

Hi
NProblem How I went and googled pastbin when I first went to post,
it did not seem to work!!
I have a dir/folder of files to upload.

It’s stuck in line 3 the rest of files is still probably got errors in them.

https://www.filepastebin.com/ ← probably wrong site.

Data

it could also be because vscode is not configured correctly. you can try to get it working with another IDE like qt creator.

That program has major syntax errors at a casual glance.

Do you have programming experience in C?

There is probably a problem in your Makefile as well. Where is that file?

2 Likes

Hi @dalto Sure there are errors iam only starting in C as the rest of the program is
is written in it, I will be sending the completed function to the creator of the original program.
They refuse/can’t do it. I get to the errors and fix them when I get past the present error.
I am more atr home in python I know enough to get by.

The make file is in the same dir/folder in vscode.

Data

I don’t see how that Makefile related to the single C file you posted.

If you just want to compile that file you can use:

gcc myprog.c -o myprog `pkg-config --cflags gtk+-3.0` `pkg-config --libs gtk+-3.0`

Of course, then you will have to start fixing all the errors in it.

1 Like

Hi
Its all a learning cycle, @dalto thanks for that.

Data

I would just warn you that C is a fairly unforgiving programming language.

Before trying to write/modify a GTK program, you will probably need to learn to program in C. It is fairly small language compared to modern languages but it is essential you understand how memory management works in C because unlike many languages, it doesn’t do that for you.

1 Like

Hi
Thanks the program I hope will be fairly simple, in function
I have ideas in my head, but when I get to compiling it VSCode
Ile have a better idea how to go about it. The main Idea for me is
just to pass a file name back to the main program which is what
I would like then hand over my Function/contribution and help integrate it.

Possibly more later or tomorrow I have things to do.

Data

Also, this appears to be C++, not C