We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Need clarification on Installing Linux header files

StarDusterII asked
Medium Priority
Last Modified: 2012-05-11
I'm new to c and Linux so I would like some clarification about: (1) why software installs the way it does and (2) what I need to do to use the software.

I'm modifying an existing c program and I wanted to add json processing to it.  Since I'm running openSUSE, I installed json-glib from their web site, did a search on json-glib, and used the one-click install to installl json-glib-devel.  Documentation says to include the following in the c program:

#include <json-glib/json-glib.h>

But that gives a compile error that says it can't be found... which makes sense because it's in json-glib-1.0/json-glib/json-glib.h.   Ok, so I change it to:

#include <json-glib-1.0/json-glib/json-glib.h>

Then I get an error that other header files don't exist because the includes in json-glib.h are:

#include <json-glib/json-types.h>
#include <json-glib/json-generator.h>
#include <json-glib/json-parser.h>
#include <json-glib/json-version.h>
#include <json-glib/json-enum-types.h>

Which is again going to the /usr/include/json-glib directory that doesn't exist.  So I'm wondering if I'm supposed to set up some kind of an alias and if so, also wondering why that isn't taken care of by some part of the install program.  

Anyway, if someone could shed a little light on this and tell me what's going on and what I need to do to fix it, I would really appreciate it.  Part of this is getting  json installed and working but another part is just a clarification of how this sort of thing is done on Linux.
Watch Question


Ok, interesting... I was messing with symbolic links and created a link from /usr/include/json-glib-1.0/json-glib to /usr/include/json-glib.  So, that made all the json-glib includes happy but in json-enum-types.h it has:

#include <glib-object.h>

Now, that file is actually in /usr/include/glib-20 but since #include <glib-object.h> is not referencing its own folder, the symbolic link approach won't work there.  So, I'm wondering how these were supposed to work together at all.  Still confused...
Top Expert 2011

> that file is actually in /usr/include/glib-20
# cd /usr/include
# ln -s /usr/include/glib-20/*.h  .


Thanks for the syntax, but first is this a normal thing to have to do to get things to compile?  Why are headers in one directory and you have to point at another?

Anyway, there are directories in /usr/include/gllib-20 too so *.h won't work.  I used:

ln -s /usr/include/glib-20 .

The files look like they are in the right place but still get a compile error.

linux-cwry:/home/stever/Projects/ComServer/ComServer # dir /usr/include/glib*
total 24
drwxr-xr-x 2 root root 4096 2010-10-30 06:58 gio
drwxr-xr-x 2 root root 4096 2010-10-30 06:58 glib
-rw-r--r-- 1 root root 2854 2010-07-05 08:15 glib.h
-rw-r--r-- 1 root root 1474 2010-07-05 08:15 glib-object.h
-rw-r--r-- 1 root root 3613 2010-07-05 08:15 gmodule.h
drwxr-xr-x 2 root root 4096 2010-10-30 06:58 gobject

linux-cwry:/home/stever/Projects/ComServer/ComServer # make
gcc -MMD -g -Wall -Wextra -Werror -Wno-unused-parameter -c src/commands.c -o build/commands.o
src/commands.c:48:25: fatal error: glib-object.h: No such file or directory
compilation terminated.
make: *** [build/commands.o] Error 1


I guess I should have included the includes:

#include <glib-object.h>
#include <json-glib/json-glib.h>

I can see the glib-object.h in terminal, like the example above, but why can't I see it in Nautilus?
Top Expert 2016
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


Sara, one of the things I hoped to get out of this is why is it done this way?... just so you can reference json-glib in your program and take care of new versions without changing the code?
Top Expert 2016

i don't know whether i understand your q. but you should see that a new version of a library not necessarily is fully compliant to version before and that developers must have the possibility to have two or more versions parallel on their systems. so putting the version number into the folder name is not the most elegant way but could easily be changed if you don't need it.

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.