Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

glib and other stuff

Status
Not open for further replies.

mover50

Programmer
Aug 3, 2004
77
0
0
US
I am trying to learn how to use glib/gtk+/gdk using C++ on linux. As far as I can tell the following components are installed.

atk-1.6.0-1
glib-1.2.10-12.1.1
gtk+-1.2.10-29.1.1
pango-1.4.1-1

They show up as such when I do a rpm -q.
When I do a man or info for each of them, nothing shows.
In addition when I use the # include <glib> or <glib-h> headers it tells me it is not found.
Also if I do a yum update for each of the apps, it tells me the most recent version is installed.

I have 3 questions.
1(. If my apps are installed, why won't the man and info work?
2(. Why can't it find the glib header?
3(. Where do I look to find headers and the standard library functions?

oh, almost forgot, my book says to use the info libg++ to find more info on stl functions, and it does not work either.

Thanks,

Kent

Kent (the worrier)
 
GNOME has GTK++ which is a visual product much like Visual C++ (if I remember right)... The best thing I can think is to try to run 'locate' to find where the headers your trying to use are... If they aren't in your include path then you'll have to add them to your include path or use the quotes.
 
You probably need to get the devel packages.

RPMs of libraries are often subdivided into a "regular" and a devel package.

A regular package contains the object files needed to link against that library. This is sufficient when all you're doing is downloading binaries that have already been compiled.

A devel package contains the headers (and probably the documentation) for the library. These are needed if you actually want to compile anything against the library (i.e. to use the library in the usual sense of the word).

You can find the devel pacakges at or a similar site (or use your distribution's "auto-get" feature if it has one). The devel packages are named just like the regular ones, but with "-devel" appended to the name.

For example, one of the packages you want to get is probably named "glib-devel-1.2.10-12.1.1".

Make sure you get a version matching the regular library package you already have!
 
GNOME has GTK++ which is a visual product much like Visual C++ (if I remember right)... The best thing I can think is to try to run 'locate' to find where the headers your trying to use are... If they aren't in your include path then you'll have to add them to your include path or use the quotes.

Keep in mind you are conversing with a genuine newbie on linux and I have not yet grasped all this stuff about setting up paths.
The only Path I know of is echo $PATH. When I do a locate, the files do not show in that Path.
What do you mean by 'include' path and how do I add to it?

You probably need to get the devel packages.
For example, one of the packages you want to get is probably named "glib-devel-1.2.10-12.1.1".


The devel packages are already installed.

Kent
 
The $PATH is an enviroment variable the list of paths to look for programs. There is also quite a few others, you can see all your enviroment variables by using the env command. Most of them take the form of VARIABLE=DIRECTORY:DIRECTORY:DIRECTORY ...

Some are just names of certian programs like:
EDITOR=vi

There may or may not be a varible LD_PATH (which would be a list of paths containing objects to link against) and there may or may not be a variable INCLUDE (which would be a list of directories holding header files which can be included). If they don't show in an env, it doesn't mean anything -- as libraries and includes are also read from certian files from certian files.

locate looks through all the directories and finds files and directorys that have names matching the passed the string. Find where the files are on your system using locate (if installed), and post the output of the locate to this thread.
 
Since no one else apparently has any suggestions, I just wanted to make sure you understood my previous post and you really do have the development packages installed.


> The devel packages are already installed.

I'm skeptical of your reply because you didn't list any development packages in your initial post, and RPM-based distros commonly install with no devel pacakges. Also, your symptoms would exactly correspond to a lack of development packages.


In your initial post, you listed pacakges like:

glib-1.2.10-12.1.1

That is not a development package.

The corresponding development package would be:

glib-devel-1.2.10-12.1.1


Apologies if you really did understand my first post, but I'm just trying to make sure.
 
I'm skeptical of your reply because you didn't list any development packages in your initial post, and RPM-based distros commonly install with no devel pacakges. Also, your symptoms would exactly correspond to a lack of development packages.

Chipper,
I am not at the pc with the package and will not be until Tuesday.
However, I am fairly sure the glib devel is installed.
I did that with a yum install glib-devel and I have done an
rpm -q glib-devel to view it.

Thanks and Regards,

Kent

Kent
 
I don't know if you solved your problem yet or not, but I just did some glib programming on a Red Hat 8.0 machine, and I found some info that might help you.

First of all, there were two versions of glib installed, so rather than having a single spot for the headers, there were two. That meant I needed to specify one using the -I option to gcc, which tells the preprocessor where to look for headers.

Second, there was an extra header file, glibconfg.h, that lived over in /usr/lib/glib-2.0/include for some reason.

Armed with that knowledge, I could compile the thing with:
Code:
gcc -c glib-app.c
    -I /usr/include/glib-2.0/
    -I /use/lib/glib-2.0/include

I then had to link it with -lglib, of course.


However, I bet you can get it to work a lot more cleanly by setting up a couple of symlinks.

Oh, and the Red Hat machine didn't seem to have any man pages or info for any of the glib stuff. Maybe it just doesn't install them, or maybe there's a separate documentation package.
 
I don't know if you solved your problem yet or not,

Gotten sidetracked and have not tried out your suggestions. Giving myself some crash learning on foxpro.
As for the no man or info, I could not find them on my FC2 either.
Thanks for the help, will put it some good use shortly, I hope.

Kent
 
I found the "right" way to include and link to glib stuff. Glib is set up to use something called pkg-config that basically generates the -I flags and whatnot that are needed to develop with a certain package.

If you say:
Code:
gcc -c glib-app.c \
    $(pkg-config --cflags glib)

gcc -o glib-app glib-app.o \
    $(pkg-config --libs glib)
you'll get the proper -I and -l flags for the default version of glib that you have installed.

In other words, it pretty much gives you the solution I used before, but it will be correct for your particular system, and your application should automatically adapt if you install a new major version of the library.

If you need a specific version, you can add, for example, "-2.0" to the end of the "glib" argument to pkg-config.


Hopefully, that'll solve the problem for glib. I'm guessing gtk probably uses pkg-config, too (since it's developed by sorta the same people), and I do not know if atk and pango use it or not. I'll check about them at some point.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top