LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-23-2005, 01:56 AM   #1
franznietzsche
Member
 
Registered: Jan 2005
Distribution: Slackware 10.1
Posts: 44

Rep: Reputation: 15
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.
 
Old 04-23-2005, 05:07 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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?).

If you have the GTK libs package installed, just:
Code:
#include <gtk/gtk.h>
And compile with:
Code:
bash$  gcc -Wall $(gtk-config --cflags) $(gtk-config --libs) -o program_name source_name.c

Last edited by Hko; 04-23-2005 at 05:10 AM.
 
Old 04-24-2005, 02:06 AM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Compiling GTK+

Hi -

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.

'Hope that helps .. PSM
 
Old 04-27-2005, 08:22 PM   #4
sisi041
LQ Newbie
 
Registered: Apr 2005
Posts: 1

Rep: Reputation: 0
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
 
Old 04-27-2005, 11:09 PM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Uh - no.

You practically *never* want to copy a system header file "someplace else".

Using "pkg-config" is the best way to go, if at all possible. Using as many "-I" include directory commands to gcc is your best alternative.
 
Old 04-28-2005, 07:02 AM   #6
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
I certainly agree with paulsm4.
The headers are in the right place. If it's not, your installation is broken and you should fix that instead.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
missing gtk+ libraries mystical_reality Linux - Software 2 10-01-2005 12:30 AM
Abiword with just GTK and not Gnome libraries -- Gentoo question vharishankar Linux - Software 8 03-30-2005 07:43 AM
GTK Libraries??? Kane635 Linux - Software 1 11-07-2004 09:23 PM
compiling gaim/ gtk error (two versions of gtk) webazoid Linux - Software 0 07-06-2004 06:05 PM
Problem with shared libraries(gtk) k0ljat Linux - Software 1 04-12-2004 01:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration