i am using ubuntu and i am learning gtk, but i can't compile the gtk code..
thanks for help

Dani AI

Generated

The usual reason GTK examples won’t compile on Ubuntu is missing development headers and build tools: the runtime libraries alone don’t provide headers or the pkg-config metadata used at compile time. For GTK 3 the development package is libgtk-3-dev, for GTK 2 it’s libgtk2.0-dev. Also make sure the compiler/meta package build-essential is installed (it pulls in gcc, make, libc-dev, etc.). (packages.ubuntu.com)

A minimal workflow that fixes most “can’t find gtk/gtk.h” or “undefined reference” errors is to install the dev packages and then compile using pkg-config so the right include/link flags are used. Example (GTK 3):

sudo apt update
sudo apt install build-essential pkg-config libgtk-3-dev

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

(Use gtk+-2.0 in the pkg-config line for GTK2.) The backticks let the shell inject the correct flags produced by pkg-config. (gstreamer.freedesktop.org)

For C# (Gtk#) and MonoDevelop points raised by : the distro package commonly used is gtk-sharp2 (Gtk# 2.x); if a newer Gtk# is required, the mono/gtk-sharp repository has build instructions and explicitly recommends installing the GTK development headers before building. Check whether the distro package satisfies the version required by MonoDevelop before building from source. (github.com)

Troubleshooting tips tied to earlier replies: was right that ATK/Pango/Cairo and friends are part of the dependency set — installing the -dev package normally pulls those in. If pkg-config --modversion gtk+-3.0 fails, the .pc file is missing (wrong package or wrong PKG_CONFIG_PATH). ’s suggestion to look for a -dev package is on track; the concrete names above remove the guesswork.

Recommended Answers

All 7 Replies

There are a lot of dependencies in order for you to install gtk. I have installed mine but I've got lot's of package lacking on my Distro, atk, pango, cairo to name a few. Be sure to have them first and make sure to visit the site John A posted. :)

pleas e help me how to install gtk+ in fedora core 7

All of you have failed miserably to answer this guys question. It's no bloody wonder more people don't understand programming. I'm in second year programming in uni and I need Gtk# 2.12.9 or greater to install MonoDevelop, and you're telling me Gtk requires other "dependencies"? this is complete nonsense in my opinion but I need this answer because I can't understand the lingo tossed around in "help" forums.

They have a FAQ with how to install it

Just download it from the net and then install it.

You need to get libgtk-dev or whatever the appropriate -dev package is called.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.