Poisson
Poisson

Reputation: 1623

glib.h cannot be found

I have a problem when compiling my C program This problem appears when i move frum ubunto 11 to ubunto 13.

When i compile with this makefile:

gcc -D_GNU_SOURCE -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/x86_64-

linux-gnu/glib-2.0/include/ -lglib-2.0 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -g -Wall

-Wextra -std=c99 -lm *.c -o formattage

I get this error:

main.c:5:18: erreur fatale: glib.h : Aucun fichier ou dossier de ce type compilation terminée.

Glib2 Dev is installed on my machine but when i check /usr/lib/glib-2.0/include this file, i didn't find it

How do I fix this?

Upvotes: 2

Views: 9721

Answers (3)

iain
iain

Reputation: 5683

As you have the development package installed you should use the correct way to compile a program linking with Glib, which is to use pkg-config to get the correct values for your system.

If you change you Makefile to something like:

gcc -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -g -Wall -Wextra -std=c99 -lm *.c -o formattage `pkg-config --cflags --libs glib-2.0`

then it will find the correct files.

Different systems and architectures install the files in different places, and to allow you to install multiple versions of Glib the files get placed in special directories. Using pkg-config solves this problem.

Upvotes: 2

Wyzard
Wyzard

Reputation: 34563

Make sure you have the libglib2.0-dev package installed, since that's what provides the glib.h header.

Library packages (such as libglib2.0-0) typically only contain the compiled libraries for use by programs that have already been compiled. To compile new programs using the associated library, you need to install the associated -dev package, which contains the library's header files.

Upvotes: 0

yokto
yokto

Reputation: 753

If you look on packages.ubuntu.com it looks like the file is in a different folder

/usr/include/glib-2.0/glib.h    libglib2.0-dev

Is the header file at that path?

Upvotes: 2

Related Questions