So this was really something I struggled with and I post this here for myself to remember as much as for the benefit of anyone else.
I'm working on a C project where we decided on using XML files as file "packets" for message parsing. The idea was that XML files would be sent around in a specific format and when the file (message) arrives at the receiving end, the XML file could easily be parsed. The problem I had was getting the libxml2 library to compile.
The following libraries were installed, under Ubuntu linux:
libxml2
libxml2-dbg
libxml2-dev
libxml2-doc
libxml2-utils
After this was done, the /libxml/parser.h file has to be included in the C file, to enable XML parsing. A complete list of functions and lots of info on the XML libraries can be found at http://www.xmlsoft.org/.
The problem was, this still did not compile correctly. For some reason, the compiler recognised the library headers, but not the functions in them. This got me thinking: "Maybe there is some issue with the object code not being found". Lots of Googling later, picking up lots of different bits and pieces from all over the Ubernet, I arrived at a solution.
It was indeed a linking issue, but quite a substantial one. If you're using Eclipse, as I was, add the following info to the Project->Properties section.
Under the Compiler->Directories section, add: /usr/include/libxml2.
Under the linker->libaries->libaries(-l) section, add: xml2.
Under the linker->libaries->search path(-L) section, add: /usr/lib.
That should do it! For all the hard-core makefile people out there, use:
LDFlags="-L/usr/lib -lxml2"
CFLAGS="-I/usr/include/libxml2/"
I hopes this saves someone some trouble! Please reply if you found this helpfull.
Friday, April 3, 2009
Subscribe to:
Posts (Atom)