Re: error when using Glib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You better use pkg-config, which by itself gives you headers and libs:

# gcc `pkg-config --libs gtk+-2.0` `pkg-config --cflags gtk+-2.0` test.c -o test

Good luck.

On Thu, May 7, 2009 at 4:24 PM, radhika sivarajan <radhika.pkd@xxxxxxxxx> wrote:
> Sir,
>
> I am a new user of Glib. I am very much impressed by its features. Could you
> please tell me how to run it in linux. I tried writing a simple array
> implementation using Glib which is given below.
>
> #include<glib.h>
> main()
> {
> GArray *garray;
>   gint i;
>   /* We create a new array to store gint values.
>      We don't want it zero-terminated or cleared to 0's. */
>   garray = g_array_new (FALSE, FALSE, sizeof (gint));
>   for (i = 0; i < 10000; i++)
>     g_array_append_val (garray, i);
>   for (i = 0; i < 10000; i++)
>     if (g_array_index (garray, gint, i) != i)
>       g_print ("ERROR: got %d instead of %d\n",
>                g_array_index (garray, gint, i), i);
>   g_array_free (garray, TRUE);
>
> }
>
> I did not know how to compile the program. I did as
>
> "[root@localhost ~]# gcc -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
> /root/test.c "
> test.c is my program. I got the error as
>
> /tmp/ccQUZw9X.o: In function `main':
> test.c:(.text+0x29): undefined reference to `g_array_new'
> test.c:(.text+0x4f): undefined reference to `g_array_append_vals'
> test.c:(.text+0xad): undefined reference to `g_print'
> test.c:(.text+0xd3): undefined reference to `g_array_free'
> collect2: ld returned 1 exit status
>
> Can you please tell me how to resolve this? I am waiting for a response.
>
> --
> Radhika S.
>
> _______________________________________________
> gtk-list mailing list
> gtk-list@xxxxxxxxx
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
>



-- 
Ricardo L. Febrero
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux