0
votes

I am an autotools newbie; I'm doing an application that needs to parse xml files, using xerces-c 3.1.

My code works fine when I install the xerces-c library with the apt-get utility (then xerces-c libraries and include files are installed in /usr/lib and /usr/include/xercesc, respectively). In my configure.ac file I have the following macro:

AC_CHECK_LIB([xerces-c],[main],[],[AC_MSG_ERROR([*** xerces-c lib not found])])  

OK, as I said, this works as expected. However, I want to have the libraries inside the project directory (to be included in the distribution package), and here my problems begin.

I uninstall the xerces-c libraries, and I copy the xerces-c libraries (downloaded from the xerces-c webpage) to my project directory. Then, I add the to my confgure.ac the macro:

    LDFLAGS="$LDFLAGS -L/home/xxxx/workspace/P3/src/lib"  

Finally, I generate the makefiles and compile, just executing the following commands in the project root directory:

  • autoconf
  • automake
  • ./configure
  • make

The compilation looks good, and the linking looks fine too:

g++  -g -O2  -L/home/xxxx/workspace/P3/src/lib -o app app-P3.o  -lxerces-c  

But when I execute the application I got an error like:

./src/app: error while loading shared libraries: libxerces-c-3.1.so: cannot open shared object file: No such file or directory  

What I'm doing wrong?
Thanks in advance.

1
"I want to have the libraries inside the project directory, and here my problems begin." Indeed, this is the beginning of many problems. The solution is to not do that! Do not treat the autotools as a package management system, as that is not their function. - William Pursell

1 Answers

0
votes

Since you are using a shared library libxerces-c-3.1.so needs to be somewhere where it can be found by ld. In the previous case where you installed the xerces-c package, libxerces was installed in /usr/lib or somewhere where it could be found. You can probably get it working for now by:

LD_LIBRARY_PATH=$PATH:/home/xxxx/workspace/P3/src/lib ./src/app

but this is something that you'll have to figure out eventually for your package install.