How to properly install Gtk libraries for compiling
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to properly install Gtk libraries for compiling
I've tried to compile a simple Gtk window over and over but have been unable too. I inculde the full directory to gtk.h (/usr/include/gtk-1.2/gtk/gtk.h) in the #include statement, but compilation never works. It prints a long list of errors, claiming that a large number of headers do not exist, when they do, right in the same directory as gtk.h. I have no idea what the problem is or what to do about it.
I'm not veryy familiar with slackware, but IRCC slackware does not ahve a seperate package for development (header) files for each library like most other distro's do (is this correct?).
Hko is absolutely correct. A couple of additional notes:
1. If your "gtk.h" header is in "/usr/include/gtk-1.2/gtk/gtk.h", then:
a) Your source file must read "#include <gtk/gtk.h>"
... and ...
b) Your "-I" compile switch must point to the gtk/ directory and not the gtk.h header:
"-I /usr/include/gtk-1.2"
2. You should be able to use "gtk-config --cflags" to get the correct GTK+ compile
flags ... and "gtk-config --libs" for the GTK+ link flags ... and "glib-config --cflags" for
the Glib compile flags ... etc etc
Just FYI, in GTK+2 all the individual "*-config" scripts have been replaced with
a single "pkg-config" script.
If you prefer, you can also just hard-code the correct flags into your makefile. In
some cases, this might actually be easier and more effective than debugging
the *config" scripts.
3. You might have different GTK+ headers in different directories. For example, on my
SuSE system, I have some of the GTK+ headers in /usr/include ... and others in
/usr/lib/gtk*/include. So you might need multiple different "-I" switches (and, when
you're past the compile errors, multiple different "-L" link siwtches).
4. Look at the *first* compile error, at the top of the errors. That will be the most important
to understand the actual problem.
vi gtk.h and find all .h file included and confirm their exists
you may find /usr/include/xx/xx1.h indeed appears in /usr/include/xx1.2/xx1.h
then copy it to right place
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.