Re: [xml] libxml2 on cygwin
- From: "Gerrit P. Haase" <gerrit familiehaase de>
- To: Mohamed Kamil Mansor <kamil axiomsol com>
- Cc: mdkamil gmail com, xml gnome org, zamani <zamani axiomsol com>
- Subject: Re: [xml] libxml2 on cygwin
- Date: Sun, 29 May 2005 04:37:18 +0200
Mohamed Kamil Mansor wrote:
Hello,
I want to share my solution on compiling program that using libxml2 on cygwin.
Cygwin already prebuild libxml2 package. However while compiling my
application, i've got error undefine reference during linking stage. I've
search all over the web but didn't get solution to my problem.
--------------- problem during compiling my applicaiton --------------------
$ make -f Makefile-cygwin
gcc -g -I/usr/include/libxml2 -DWINDOWS -o ald.o -c ald.c
gcc -g -I/usr/include/libxml2 -L/usr/lib -lxml2 -lz -liconv -lm -o ald ald.o
ald.o(.text+0x1217): In function `parseProjfile':
ald-v0.7/ald.c:392: undefined reference to `_xmlParseFile'
ald.o(.text+0x1256):ald-v0.7/ald.c:397: undefined reference to
`_xmlDocGetRootElement'
ald.o(.text+0x1282):ald-v0.7/ald.c:401: undefined reference to `_xmlFreeDoc'
ald.o(.text+0x12a4):ald-v0.7/ald.c:405: undefined reference to `_xmlStrcmp'
ald.o(.text+0x12cb):ald-v0.7/ald.c:407: undefined reference to `_xmlFreeDoc'
ald.o(.text+0x138d): In function `parseData':
ald-v0.7/ald.c:429: undefined reference to `_xmlStrcmp'
ald.o(.text+0x13da):ald-v0.7/ald.c:434: undefined reference to
`_xmlNodeListGetString'
ald.o(.text+0x13f3):ald-v0.7/ald.c:435: undefined reference to `_xmlStrcmp'
collect2: ld returned 1 exit status
make: *** [ald] Error 1
---------------------------- end -------------------------
xml2-config output:
$ xml2-config --libs
-L/usr/lib -lxml2 -lz -liconv -lm
$ xml2-config --cflags
-I/usr/include/libxml2
part of content file: /usr/lib/libxml2.la
--------------- snap -------------------
# The name that we can dlopen(3).
dlname='../bin/cygxml2-2.dll'
# Names of this library.
library_names='libxml2.dll.a'
-------------- snip ------------------
As described in libxml2.la file, the dlname='../bin/cygxml2-2.dll' which
located in /usr/bin/cygxml2-2.dll. However the actual cygxml2-2.dll file
located at /bin and not at /usr/bin.
So i've changed /usr/lib/libxml2.la file into:
--------------- snap -------------------
# The name that we can dlopen(3).
dlname='/bin/cygxml2-2.dll'
# Names of this library.
library_names='libxml2.dll.a'
-------------- snip ------------------
Then i've also add options "--dll-search-prefix=cyg -L/bin -lxml2-2" during
linking process.
--------------- compilation success with no error ----------------
$ make -f Makefile-cygwin
gcc -g -I/usr/include/libxml2 -DWINDOWS -o ald.o -c ald.c
gcc -g -I/usr/include/libxml2 -L/usr/lib -lxml2 -lz -liconv -lm
--dll-search-prefix=cyg -L/bin -lxml2-2 -o ald ald.o
---------------- end -------------------------
Hopefully, this solutions will help other peoples that face same problem with
me. Good luck.
This is wrong though it works.
You need to use the tools as they are meant to be used:
The libraries must be at the beginning of the link command,
the linker reads the command from right to left, so try this:
gcc -g -o ald ald.o -L/usr/lib -lxml2 -lz -liconv -lm
and you're done.
Regards,
Gerrit
--
=^..^=
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]