Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eclipse CDT glib libraries inclusion error

I have a created C based project with CDT from pidgin source code. Everything is working fine but it says unresolved inclusion for following two libs:

#include <libxml/parser.h>
#include <glib.h>

How can I fix this?
I can't use CDT hover, open declarations etc. features with the functions of this library and have to manually browse in the directories. I have tried adding the lib directory in project properties -> paths and symbols.

like image 206
crodjer Avatar asked Dec 17 '10 17:12

crodjer


2 Answers

Firt you should make sure that the developer packages for glib and libxml are installed. On ubuntu you can type:

apt-get install libxml2-dev libglib2.0-dev

Then you van watch with pkg-config which directories should be included

~> pkg-config --cflags libxml-2.0
-I/usr/include/libxml2
~> pkg-config --cflags glib-2.0
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include

The above are the header files which are to be configured in the Compiler settings (in CDT you should strip the '-I'). Below are the libraries that are needed by the linker so configure them at the linker settings in CDT and strip the '-l'

 ~>pkg-config --libs libxml-2.0
 -lxml2
 ~>pkg-config --libs glib-2.0
 -lglib-2.0

If you still get unresolved includes you should try to clean the project in CDT.

Owh BTW: the include directories and libraries should not be configured in C/C++->Paths and Symbols (though that should work as well) but I always configure them in C/C++ Build->Settings

like image 103
LittleFunnyMan Avatar answered Sep 28 '22 09:09

LittleFunnyMan


For me it worked by going to Project Properties->C/C++ General->Paths and Symbols->Tab "Includes" and add an entry under "GNU C" with the library's path /usr/include/glib-2.0

Eclipse Oxygen CDT on Ubuntu 18.04 LTS

like image 45
tryfonaration Avatar answered Sep 28 '22 08:09

tryfonaration