0

I am attempting to compile some very simple code that uses the glib library. I am getting undefined reference compiler errors to my glib functions.

Is there a glib library I am supposed to include? I'm not finding much references on the internet.

Below is the simple code:

#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <glib/garray.h>
#include <glib/gtypes.h>

int main(int argc, char** argv)
{
    GArray* test = g_array_new(1, 1, 5); // undefined reference to g_array_new

    g_array_free(test, 1);  // undefined reference to g_array_free
    return 0;
}

I am currently including the libraries: -ldbus-1 -lbluetooth -lncurses. And including the directories: -I/usr/include/glib-2.0/ -I../../../bluez-5.39 -I/usr/include/x86_64-linux-gnu -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/lib/x86_64-linux-gnu/glib-2.0/include.

sazr
  • 24,984
  • 66
  • 194
  • 362

1 Answers1

0

I needed to include -lglib-2.0

sazr
  • 24,984
  • 66
  • 194
  • 362