Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Can't include library to main file in GCC

Not open for further replies.


Member level 2
May 10, 2004
Reaction score
Trophy points
Activity points
I would like to include glib.h in my main file. But I could not link this file to my main file called test.c.

include <glib.h>

int main()

I even use the command gcc test.c -I/usr/include/glib-2.0

When I use using the GUI of KDevelop to compile, the same problem arises which says invalid file or directory (glib.h). Before creating the project I even added the include path. Help.... I'm new to Linux...

Thank you very much...

Including Library

If gcc can't find an include file, it normally says something like this:
test.c:3:18: glib.h: No such file or directory

Are you sure that /usr/include/glib-2.0/glib.h is a good readable file?

Re: Including Library

Yes, I got the message: test.c:3:18: glib.h: No such file or directory
I even look for it under the directory and the file is there. Even read it using 'cat' command. I don't quite get you on the 'good readable file' thing.

Including Library

The "invalid file or directory" message may have meant the file or path was somehow inaccessible or unreadable, but if you are now getting "no such file or directory", then the problem seems to be a simple directory path issue. You specified the full include path on the command line, so it should work. It works for me running GCC under Linux.

Just for giggles,
Try putting the full explicit path into your #include <...>
Try changing it to #include "..."
Not open for further replies.

Part and Inventory Search

Welcome to