Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » libxml2(compile and link libxml2)
libxml2 [message #818846] Mon, 12 March 2012 03:30 Go to next message
Eclipse UserFriend
I try to use libxml2 in a C++ project, and I use Eclipse to edit and compile

On Ubuntu I have install libxml2 by execute following command:
sudo apt-get install libxml2-dev


On the link
xmlsoft.org FAQ.html#Developer
I have found information about lib and compile flags


Running this on the command line
xml2-config --cflags
gives
-I/usr/include/libxml2

Running this on the command line
xml2-config --libs
gives
-lxml2

In ordinary Makefile I should write:

CFLAGS=`xml2-config --cflags`

LIBS=`xml2-config --libs`

In the menu:
Project\settings\Tool Settings\GCC C++ Linker\Miscellaneous\Linker flags
I have enter -lxml2

Where shall I insert following line in eclipse
-I/usr/include/libxml2


I have tried to
In the menu:
Project\settings\Tool Settings\GCC C++ Compiler\Ditrectory\Include Path (-I)
/usr/include/libxml2
/usr/include/libxml2/libxml




I got following errors:

./rfmsweb/src/rfms/rfmscore/Configuration.o: In function `~Configuration':
/home/ajn/workspace/rfms1/Debug/../rfmsweb/src/rfms/rfmscore/Configuration.cpp:22: undefined reference to `xmlFreeDoc'
./rfmsweb/src/rfms/rfmscore/Configuration.o: In function `rfms::Configuration::load(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/ajn/workspace/rfms1/Debug/../rfmsweb/src/rfms/rfmscore/Configuration.cpp:27: undefined reference to `xmlParseFile'
./rfmsweb/src/rfms/rfmscore/UUID.o: In function `UUID':
/home/ajn/workspace/rfms1/Debug/../rfmsweb/src/rfms/rfmscore/UUID.cpp:15: undefined reference to `uuid_copy'
/home/ajn/workspace/rfms1/Debug/../rfmsweb/src/rfms/rfmscore/UUID.cpp:20: undefined reference to `uuid_parse'




Re: libxml2 [message #818943 is a reply to message #818846] Mon, 12 March 2012 05:56 Go to previous messageGo to next message
Eclipse UserFriend
I have now try to reinstall the package

sudo apt-get --reinstall instal libxml2-dev

But I get the same error.

What I can see is that I am able to compile but not link.

I can also see that both -L/usr/lib and -lxml2 is specified

Does anyone have a clue what I should do to catch this problem?


Building target: rfms1
Invoking: GCC C++ Linker
g++ -L/usr/lib -pthread -lrt -lxml2 -o"rfms1" ./rfmsweb/src/rfms/web/cgi/scgi/SCGIHandler.o ./rfmsweb/src/rfms/web/cgi/scgi/SCGIRequest.o ./rfmsweb/src/rfms/web/cgi/scgi/SCGIResponse.o ./rfmsweb/src/rfms/web/cgi/scgi/SCGIServer.o ./rfmsweb/src/rfms/web/cgi/CGIHandler.o ./rfmsweb/src/rfms/web/cgi/CGIRequest.o ./rfmsweb/src/rfms/web/cgi/CGIResponse.o ./rfmsweb/src/rfms/web/Application.o ./rfmsweb/src/rfms/web/CacheControl.o ./rfmsweb/src/rfms/web/Component.o ./rfmsweb/src/rfms/web/Content.o ./rfmsweb/src/rfms/web/Context.o ./rfmsweb/src/rfms/web/Control.o ./rfmsweb/src/rfms/web/Cookie.o ./rfmsweb/src/rfms/web/Directory.o ./rfmsweb/src/rfms/web/Document.o ./rfmsweb/src/rfms/web/Error.o ./rfmsweb/src/rfms/web/FileResource.o ./rfmsweb/src/rfms/web/Folder.o ./rfmsweb/src/rfms/web/MemoryResource.o ./rfmsweb/src/rfms/web/MimeUtil.o ./rfmsweb/src/rfms/web/Parser.o ./rfmsweb/src/rfms/web/ParserException.o ./rfmsweb/src/rfms/web/Request.o ./rfmsweb/src/rfms/web/Resource.o ./rfmsweb/src/rfms/web/ResourceManager.o ./rfmsweb/src/rfms/web/Response.o ./rfmsweb/src/rfms/web/SecurityDescriptor.o ./rfmsweb/src/rfms/web/Session.o ./rfmsweb/src/rfms/web/SessionManager.o ./rfmsweb/src/rfms/web/Status.o ./rfmsweb/src/rfms/web/TextContent.o ./rfmsweb/src/rfms/web/TextUtil.o ./rfmsweb/src/rfms/web/User.o ./rfmsweb/src/rfms/web/UserManager.o ./rfmsweb/src/rfms/rfmscore/graphic/Bitmap.o ./rfmsweb/src/rfms/rfmscore/graphic/Canvas.o ./rfmsweb/src/rfms/rfmscore/graphic/GraphicException.o ./rfmsweb/src/rfms/rfmscore/graphic/Image.o ./rfmsweb/src/rfms/rfmscore/Configuration.o ./rfmsweb/src/rfms/rfmscore/ConfigurationException.o ./rfmsweb/src/rfms/rfmscore/ConfigurationGroup.o ./rfmsweb/src/rfms/rfmscore/ConfigurationItem.o ./rfmsweb/src/rfms/rfmscore/Exception.o ./rfmsweb/src/rfms/rfmscore/Localization.o ./rfmsweb/src/rfms/rfmscore/Mutex.o ./rfmsweb/src/rfms/rfmscore/Property.o ./rfmsweb/src/rfms/rfmscore/Socket.o ./rfmsweb/src/rfms/rfmscore/Socket4.o ./rfmsweb/src/rfms/rfmscore/SocketException.o ./rfmsweb/src/rfms/rfmscore/SocketStream.o ./rfmsweb/src/rfms/rfmscore/StringUtil.o ./rfmsweb/src/rfms/rfmscore/Thread.o ./rfmsweb/src/rfms/rfmscore/UUID.o ./rfmsweb/src/rfms/main.o
./rfmsweb/src/rfms/rfmscore/Configuration.o: In function `~Configuration':
/home/ajn/workspace/rfms1/Debug/../rfmsweb/src/rfms/rfmscore/Configuration.cpp:22: undefined reference to `xmlFreeDoc'
./rfmsweb/src/rfms/rfmscore/Configuration.o: In function `rfms::Configuration::load(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/ajn/workspace/rfms1/Debug/../rfmsweb/src/rfms/rfmscore/Configuration.cpp:27: undefined reference to `xmlParseFile'
./rfmsweb/src/rfms/rfmscore/UUID.o: In function `UUID':
Re: libxml2 [message #818956 is a reply to message #818943] Mon, 12 March 2012 06:14 Go to previous messageGo to next message
Eclipse UserFriend
OK I have dowload a example now that is using the libxml2, and it working just fine. I am able to compile and link the program with following command.

gcc -o example `xml2-config --cflags` example.c `xml2-config --libs`

So the question is how do I enter this line in Eclipse?

[Updated on: Mon, 12 March 2012 06:18] by Moderator

Re: libxml2 [message #819726 is a reply to message #818956] Tue, 13 March 2012 04:58 Go to previous messageGo to next message
Eclipse UserFriend
You forgot to tell the linker about library.
http://wiki.eclipse.org/CDT/User/FAQ#Adding_C.2FC.2B.2B_External_Libraries

Re: libxml2 [message #819795 is a reply to message #819726] Tue, 13 March 2012 06:36 Go to previous message
Eclipse UserFriend
Thanks a lot Axel. The problem is now resolved.

Exactly as you said

In GCC C++ Linker window

I had to add both
Libraries
(i)
xml2


Libraries search path
/usr/lib

Thanks again
Previous Topic:C/C++ MinGW debug problem
Next Topic:Watch expression in C/C++ Project is possible??
Goto Forum:
  


Current Time: Fri Jun 13 19:32:19 EDT 2025

Powered by FUDForum. Page generated in 0.04550 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top