Undefined reference to 'glib'
Posted
by
dali1985
on Stack Overflow
See other posts from Stack Overflow
or by dali1985
Published on 2013-07-02T10:51:47Z
Indexed on
2013/07/02
11:05 UTC
Read the original article
Hit count: 742
I would like to parse a config file using glib in Codeblocks which I use. So I want to do exactly the example which is described here first. I have a file named myconfig.cfg and and a code programming.c. I just copy and paste the code to see if glib works but unfortunately it does not work. I did the installation of glib2.0 using sudo apt-get, I found where are the libs in glibs using
pkg-config --cflags --libs glib-2.0
and in this path
project->Build Options->Compiler Settings-> Other Options
I added
-I/usr/include/glib-2.0 -I/usr/lib/arm-linuxgnuebihf/glib-2.0/include
When I build and run the programming.c I have these errors
-------------- Build: Debug in programming ---------------
gcc -Wall -g -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -std=c99 -c /home/pi/Desktop/programming/main.c -o obj/Debug/main.o
g++ -o bin/Debug/programming obj/Debug/main.o /usr/lib/libmysqlclient.so.16
obj/Debug/main.o: In function `main':
/home/pi/Desktop/programming/main.c:22: undefined reference to `g_key_file_new'
/home/pi/Desktop/programming/main.c:26: undefined reference to `g_key_file_load_from_file'
/home/pi/Desktop/programming/main.c:28: undefined reference to `g_log'
/home/pi/Desktop/programming/main.c:34: undefined reference to `g_slice_alloc'
/home/pi/Desktop/programming/main.c:37: undefined reference to `g_key_file_get_string'
/home/pi/Desktop/programming/main.c:39: undefined reference to `g_key_file_get_locale_string'
/home/pi/Desktop/programming/main.c:41: undefined reference to `g_key_file_get_boolean_list'
/home/pi/Desktop/programming/main.c:43: undefined reference to `g_key_file_get_integer_list'
/home/pi/Desktop/programming/main.c:45: undefined reference to `g_key_file_get_string_list'
/home/pi/Desktop/programming/main.c:47: undefined reference to `g_key_file_get_integer'
/home/pi/Desktop/programming/main.c:49: undefined reference to `g_key_file_get_double_list'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 6 seconds)
11 errors, 0 warnings
Am I missing something? I tried also to do in the same way with libconfig but again I have undefined reference. Is the problem the path?
© Stack Overflow or respective owner