Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: GLIB in C programming: No such file or directory

  1. #1
    Join Date
    Sep 2019
    Beans
    11

    GLIB in C programming: No such file or directory

    I a have C file where the
    where when I execute it via terminal:
    Code:
    gcc test.c -o test
    I get the error
    fatal error: glib-object.h: No such file or directory

    I also tried
    Code:
    gcc -O2 $(pkg-config --cflags glib-2.0) -o test test.c $(pkg-config --libs glib-2.0)
    The headers of the C file

    Code:
    #include <stdlib.h>
    #include <stdio.h>
    #include <glib-object.h>
    #include <json-glib/json-glib.h>

  2. #2
    Join Date
    Dec 2014
    Beans
    1,203

    Re: GLIB in C programming: No such file or directory

    Do you have the developers package for glib 2.0 (libglib2.0-dev) installed ? Just having the library does not give you the headers, they are in the *-dev packages.
    Also, 'pkg-config --libs' outputs the '-l' option for the linker-part of the gcc toolchain, it doesn't produce the '-I' option for the preprocessor which gives paths for the headers. You probably want 'pkg-config --cflags --libs glib-2.0' which does both.

    Holger

  3. #3
    Join Date
    Sep 2019
    Beans
    11

    Re: GLIB in C programming: No such file or directory

    How do I install the developers package for glib 2.0?

  4. #4
    Join Date
    Dec 2014
    Beans
    1,203

    Re: GLIB in C programming: No such file or directory

    Code:
    sudo apt install libglib2.0-dev
    in a terminal or with synaptic.

    Holger

  5. #5
    Join Date
    Sep 2019
    Beans
    11

    Re: GLIB in C programming: No such file or directory

    After I installed:

    Code:
    sudo apt install libglib2.0-dev
    And I execute
    Code:
    gcc test.c -o test
    The first error:
    fatal error: glib-object.h: No such file or directory

    Changes in to:
    fatal error: json-glib/json-glib.h: No such file or directory




  6. #6
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: GLIB in C programming: No such file or directory

    Did you install json-glib dev package?

  7. #7
    Join Date
    Dec 2014
    Beans
    1,203

    Re: GLIB in C programming: No such file or directory

    According to https://packages.ubuntu.com json-glib.h is in the package 'libjson-glib-dev'.

    Holger

  8. #8
    Join Date
    Sep 2019
    Beans
    11

    Re: GLIB in C programming: No such file or directory

    After I installed
    Code:
    sudo apt-get install libjson-glib-dev
    When I try
    gcc test.c -o test

    The first error came back:
    fatal error: glib-object.h: No such file or directory

    When I try
    Code:
    gcc -O2 $(pkg-config --cflags glib-2.0) -o test test.c $(pkg-config --libs glib-2.0)
    Changes in to:
    fatal error: json-glib/json-glib.h: No such file or directory
    Last edited by jenniferruurs; 4 Weeks Ago at 08:49 AM.

  9. #9
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,510
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: GLIB in C programming: No such file or directory

    Quote Originally Posted by jenniferruurs View Post
    After I installed
    Code:
    sudo apt-get install libjson-glib-dev
    When I try
    gcc test.c -o test

    The first error came back:
    fatal error: glib-object.h: No such file or directory

    When I try
    Code:
    gcc -O2 $(pkg-config --cflags glib-2.0) -o test test.c $(pkg-config --libs glib-2.0)
    Changes in to:
    fatal error: json-glib/json-glib.h: No such file or directory
    You need to tell the compiler where to find the necessary from your newly added package.
    Code:
    gcc -O2 $(pkg-config --cflags glib-2.0 json-glib-1.0) -o test test.c $(pkg-config --libs glib-2.0 json-glib-1.0)

  10. #10
    Join Date
    Sep 2019
    Beans
    11

    Re: GLIB in C programming: No such file or directory

    Thank you this did worked!

    Is there a way how I can added these files to gcc so that
    Code:
    gcc test.c -o test
    Would also work?

    Or isn't that possible?

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •