I am building an application in C on linux platform. In my program, I read XML document using libxml2 using the API xmlReadFile().
I link the program as below (line from makefile):
$(CC) -m32 -g -o app.out -Wl,-Bstatic $(other_libs) -lmysqlclient -lxml2 -Wl,-Bdynamic -lpthread -lm -lrt -lz -lbz2 $(extra_ldflags)
With these settings everything works file. The API call to xmlReadFile() works fine.
If I move -lmysqlclient after -lxml2 the program generates below error in xmlReadFile().
File.xml:1: parser error : Document is empty
^
File.xml:1: parser error : Start tag expected, '<' not found
^
I actually want to link to mysql client dynamically (because I have libmysqlclient_r.so but not libmysqlclient_r.a and I want to use libmysqlclient_r.so because my application is multithreaded). Even if I keep the link order same and specify dynamic linking of mysql client library as below, I get the above mentioned error.
$(CC) -m32 -g -o app.out -Wl,-Bstatic $(other_libs) -Wl,-Bdynamic -lmysqlclient -Wl,-Bstatic -lxml2 -Wl,-Bdynamic -lpthread -lm -lrt -lz -lbz2 $(extra_ldflags)
How do I resolve the above mentioned error?
I thank you in advance for your help.