Re: [xml] libxml2: Linker problem on Cygwin



Jitesh Verma wrote:

Hi List,

I am new to XML and libxml.

I tried to compile a simple XML test application provided in the libxml tutorial,. I am linking my test app with libxml2.a provided with cygwin (version - 1.3.22 (CYGWIN_NT-5.0)) running on Win2k.



My makefile is as follows:



g++ -DLIBXML_STATIC -I/usr/include/libxml2/libxml -I/usr/include/libxml2 -c test.c

g++ -DLIBXML_STATIC -L/usr/lib -lxml2 -lxml2.dll -lz -o test test.o



It gives the following errors:

-------------------------

test.o(.text+0x3f):test.c: undefined reference to `_xmlStrcmp'

test.o(.text+0x60):test.c: undefined reference to `_xmlNodeListGetString'

test.o(.text+0x81):test.c: undefined reference to `_xmlFree'

test.o(.text+0x127):test.c: undefined reference to `_xmlParseFile'

test.o(.text+0x158):test.c: undefined reference to `_xmlDocGetRootElement'

test.o(.text+0x184):test.c: undefined reference to `_xmlFreeDoc'

test.o(.text+0x19f):test.c: undefined reference to `_xmlStrcmp'

test.o(..text+0x1c6):test.c: undefined reference to `_xmlFreeDoc'

test..o(.text+0x1ef):test.c: undefined reference to `_xmlStrcmp'

test.o(.text+0x21b):test.c: undefined reference to `_xmlFreeDoc'

collect2: ld returned 1 exit status

----------------------------



It seems g++ is able to link libxml to my test application. I tried replacing g++ with gcc, but got the same result.

I tried various permutation/combination of compiler options, include, lib paths etc., but no effect. Please note that libxml2.a, libxml2.dll.a are available under both /lib and /usr/lib on cygwin and XML headers are available under /usr/include/libxml2/libxml.



Could you please tell me what is going wrong? How to resolve this problem?

Please help me.


There is no static libxml for Cygwin.  You need to compile it yourself
if you must have it linked in statically.

To use the shared library try this:

 g++ -I/usr/include/libxml2/libxml -I/usr/include/libxml2 -c test.c
 g++ -o test test.o -L/usr/lib -lxml2 -lz -liconv -lm


Regards,
Gerrit


--
=^..^=



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]