5

I need to add a C library to C project in Eclipse indigo. What I've done so far. I've downloaded and installed the library. All headers are in folder /usr/include, library.so files are in folder /usr/lib. After having read a tutorial I tried to do it like this: When in Eclipse -> Project -> C/C++ Build -> Settings -> GCC C Linker -> Libaries -> Add libary -> "ibxml2" ( library name is libxml2 ) But it still doesn't work. I am a super newbie at Linux, so please could you give me some advise how to do that? there is a screenshot, that might be helpfful

By the way one more thing. After creating a new C/C++ Project when I run an error occurs " Launch failed! Binary not found". I checked "Binary Parsers" in Project's Settings and "Elf Parser" is set ( I've read that it is OK for Linux ), so what is wrong? It is not so important, since it works when I first only build project and then run it, but maybe there is a way to solve that too?

koleS
  • 1,263
  • 6
  • 30
  • 46

1 Answers1

3

In linker options, you should not add "libxml2", but just "xml2". All binary libraries in Linux (so files) have a "lib" prefix that is not a part of library name.

ghik
  • 10,706
  • 1
  • 37
  • 50
  • It still doesn't work I get such an error: /usr/local/include/libxml2/libxml/xmlmemory.h:16:31: fatal error: libxml/xmlversion.h: There is no such file or folder. ( I checked the folder and that file is there, but maybe something is wrong with this path - it is shorter only libxml/xmlversion.h ) ? – koleS Dec 03 '11 at 20:56
  • 2
    Looks like the library itself references its headers treating `/usr/local/include/libxml2/` as a root directory for its includes. As for me, this is strange, but adding this directory to 'C/C++ Build -> Settings -> GCC C Compiler -> Includes' should be a quick solution. – ghik Dec 03 '11 at 21:13
  • That worked and I can include headers from that library, however when I try to run an exmaple from that library I still get errors like "undefined reference to some methods". I checked headers I've included and they contain those methods, but it seems like .c files are missing here. Any idea how to solve it? – koleS Dec 03 '11 at 21:59
  • Ok it works now, as you said I added path to C complier includes and xml2 to C Linker libraries - thanks a lot! – koleS Dec 03 '11 at 23:11