Email: bknpk@hotmail.com Phone: +972-54-7649119

 

ASIC/FPGA Design and Verification Out Source Services

A very simple example to Manage C data using the GLib library.


  1. My first step was to run the example from Glib tutorial.

  2. To install Glib on my debian machine, I need to fire this command, as super-user:
    apt-get install libglib2.0-dev


  3. To find the required libraries to compile and link the simple Glib example:
    pkg-config --cflags --libs glib-2.0

    Then compiled and linked:
    gcc -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -lglib-2.0 -o try try.c

  4. The code is listed below. Note that I slightly modified the code.

    1. #include <stdlib.h>
    2. #include <stdio.h>
    3. #include <glib.h>
    4. int main(int argc, char** argv) {
    5.   GList* list = NULL;
    6.   list = g_list_append(list, "Hello world!");
    7.   printf("The first item is '%s'\n", g_list_first(list)->data);
    8.   return 0;
    9. }

  5. You may be interested also in :
    GHDL c interfaces and extensions.
    My first cpp program to work on text.