Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Libxml2: undefined reference to xmlTextReaderConstName

I have installed the latest libxml2-2.8.0, as usual: $ ./configure, $ make, $ make install.

The $ xml2-config --cflags --libs gives this output:

-I/usr/local/include/libxml2
-L/usr/local/lib -lxml2 -lm

But trying to compile any example...

$ gcc `xml2-config --cflags --libs` xmltest.c

The linker says:

/tmp/cc8ezrPl.o: In function `processNode':
xmltest.c:(.text+0x19): undefined reference to `xmlTextReaderConstName'
xmltest.c:(.text+0x38): undefined reference to `xmlTextReaderConstValue'

...etc.

Anything I've googled can be solved by xml2-config --cflags --libs flags, or upgrading to the latest version of libxml2, or something. Unfortunately, neither works for me.

What can be the steps to identify the problem?

Using Ubuntu 12.04 64-bit.

like image 867
Dmitry Isaev Avatar asked Dec 20 '22 20:12

Dmitry Isaev


1 Answers

The libraries should be specified only after the source file so that the linker can resolve the undefined references in the source file. Try compiling the example with this

gcc -I/usr/local/include/libxml2 -L/usr/local/lib xmltest.c -lxml2 -lm
like image 63
panickal Avatar answered Dec 28 '22 07:12

panickal