MarkBeauchene
Posts: 23
Joined: Sat Nov 04, 2017 6:40 pm

Need Help Using GTK+

Fri Mar 02, 2018 6:03 pm

I have looked around and found several places with explanations, but so far I haven't found one that works.

The best one so far says to run the sudo apt-get install libgtk-3-dev . This does seem to run ok.

The next step is to do something with a makefile. Sorry, I have o idea what this is, or how to do it.

I tried mixing the information I received, but some of it is from 2.0 and some from 3.0, and they don't play together nicely. I tried gcc with the pkg-config and get a message No such file or directory. I tried gcc without pkg-config, and see that there is no gtk.h anywhere on the RPI.

User avatar
MikeG58
Posts: 32
Joined: Thu Jan 05, 2017 7:09 am

Re: Need Help Using GTK+

Fri Mar 02, 2018 6:30 pm

Mark,

Ooph! You sound like me about a month or two ago.

My best advice to you is to read Peter O's tutorial. It finally got me off the starting line.

http://www.peteronion.org.uk/GtkExample ... rials.html

Now, the question is, and I think I can gather from your post that you're not using an IDE? I use Geany, and seem to have success passing the command line $( pkg-config gtk+-3.0 --cflags --lib) onto the gcc compiler. It's done under Build - Set Build Commands. There are options to set for the Compiler and Options for the Builder. I have to admit, I'm confused as to the differences, but, it seems pretty forgiving.

What is really great to learn with GTK+ is using it with Glade. You can use Glade to gin together your User Interface. When you can get it to work, it works great.

Please keep me posted as to your progress and discoveries.

-Mike

User avatar
MikeG58
Posts: 32
Joined: Thu Jan 05, 2017 7:09 am

Re: Need Help Using GTK+

Fri Mar 02, 2018 6:42 pm

Mark,

Let me address some of the confusion, and, yeah, the whole C++/GTK+ world is confusing to a newbie like me.
The best one so far says to run the sudo apt-get install libgtk-3-dev . This does seem to run ok.
OK, that package is one that you have to have installed in order to create gtk+ programs. Without that, you're spinning your wheels, so, it's good that you've installed that. That package, if I'm not mistaken, provides the header files for gtk. In a C program, you'll need an
#include <gtk/gtk.h> in order for gtk commands to work.
The next step is to do something with a makefile. Sorry, I have o idea what this is, or how to do it.
You and me both on that one. All the tutorials and answers I've received from others trying to explain those have been more confusing than my questions. I do know, that when you compile source code, it provides a makefile. After you expand your tarball that a source file is included in, the make file is part of the source tree. But, how it's implemented with C/C++ files, or how to create your own make files, and them implement them, I'm still not sure about. I'm very new to the Linux environment, and though I've been hard at learning it for a while, and pieces are just starting to fit together, I still have l long way to go to get on top of things.

Again, I would recommend Peter O's tutorial: http://www.peteronion.org.uk/GtkExample ... rials.html

At least I can get his examples to run.

-Mike

Return to “C/C++”