C++ – xerces-c 2.8 : error while loading shared libraries


I'm trying to compile a program running on an HP UX server on a Red Hat Linux.

It uses xerces-c library to parse xml files. Compilation is ok, but when i try to run it, I get the following message

./a.out: error while loading shared
libraries: libxerces-c.so.28: cannot
open shared object file: No such file
or directory

I wrote a very simple program to try and understand whats going on:

#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/TransService.hpp>
#include <xercesc/parsers/SAXParser.hpp>
#include <xercesc/util/OutOfMemoryException.hpp>

int main(int argc, char* argv[])
        return 0;

And compiled it like this:

g++ test.cpp
-L./xml/xerces-c_2_8_0/lib -lxerces-c -I./xml/xerces-c_2_8_0/include

Surprisingly the file is actually there:

lib]$ ls
libxerces-c.a   libxerces-c.so.28    libxerces-depdom.a   libxerces-depdom.so.28
libxerces-c.so  libxerces-c.so.28.0  libxerces-depdom.so  libxerces-depdom.so.28.0

Any thoughts ? I feel i'm missing something, but don't know what.

Thanks in advance.

Best Solution

run ldd a.out and see if the linker can resolve the right .so file

export LD_LIBRARY_PATH to include the current folder (in the same manner as the PATH variable) and check ldd again

Related Question