Check build parameters of libxml2.so at runtime

110 views Asked by At

I am writing a simple application that links to libxml2 on the system. It works for almost all users, but one user reported this error when reading a particular xml file from the web:

Unsupported encoding ISO8859-1

This error typically indicates that libxml2 was built --without-iconv. Is there any way I can explicitly test if the libxml2 dynamic library on the system has iconv support?

1

There are 1 answers

1
Craig S. Anderson On BEST ANSWER

I can think of two ways to do this:

  1. Write a short, simple test program that uses the iconv feature of xml. It should behave differently if it is not present. This is what the GNU configure software does - it tests for features being present by exercising them.
  2. This is a hack - find a common iconv symbol present in libxml with iconv but not if iconv is missing. Use a utility like nm to list the symbols in the library file.

Or just avoid the issue by packaging a working libxml with your application.