Libxml2: undefined reference to xmlTextReaderConstName
gcc, libxml2, linker
Solution
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
Problem
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.