22

I'm running eclipse on Ubuntu using a g++ compiler and I'm trying to run a sample program that utilizes xerces.

The build produced no errors however, when i attempted to run the program, I would receive this error:

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

libxerces-c-3.1.so is in the directory /opt/lib which I have included as a library in eclipse. The file is there when I checked the folder. When I perform an echo $LD_LIBRARY_PATH, /opt/lib is also listed.

Any ideas into where the problem lies? Thanks.

An ldd libxerces-c-3.1.so command yields the following output:

linux-vdso.so.1 => (0x00007fffeafff000)
libnsl.so.1 => /lib/libnsl.so.1 (0x00007fa3d2b83000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007fa3d2966000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fa3d265f000)
libm.so.6 => /lib/libm.so.6 (0x00007fa3d23dc000)
libc.so.6 => /lib/libc.so.6 (0x00007fa3d2059000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fa3d1e42000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa3d337d000)
guntbert
5366 silver badges19 bronze badges
asked Dec 23, 2010 at 0:40
1

5 Answers 5

33

Try running ldconfig as root to see if it solves the problem.

Peter O.
33.1k14 gold badges86 silver badges97 bronze badges
answered Feb 22, 2012 at 13:06
Sign up to request clarification or add additional context in comments.

2 Comments

I tried running sudo ldconfig but it still doesn't work
Of course it didn't @Nubcake. Do this echo /opt/lib > /etc/ld.so.conf.d/my-bonus-library-path.conf or suitable equivalent for your case, as root. Then ldconfig. ld.so needs to know where to look for libraries; and it uses a cache, ldconfig rebuilds that cache.
4

Run ldd libxerces-c-3.1.so and examine the output to see if all dependencies can be found.

answered Dec 23, 2010 at 0:45

1 Comment

I've edited the topic with the result from an ldd command. I'm fairly new to linux so I'm not quite sure what the output means. How do I know if I have all the shared libraries required? Are those the ones listed with the arrows?
4

There are many ways to do this, most already mentioned here. BUT you want to avoid accidentally copying your library files into/over those of the system. This is easily done since people have little imagination in making original unique names for their libraries.

So there are a couple of things to think about:

  • Do you need these files to be a permanent part of your system?
  • Do you only need to install for testing and frequent updates?
  • Do you only need them for running that particular command once or twice?
  • Where are your native libraries located?

To find your various library locations on your system (apart from using find), look here:

cat /etc/ld.so.conf 
cat /etc/ld.so.conf.d/*

On Linux there are some standard places:

/lib # for base system (don't use this!)
/usr/lib # for package manger installed apps 
/usr/local/lib # for user installed apps

There are many others, but you should most likely stay with /usr/local/lib. Next you need to tell your system where to find these libraries. The cool system dude (who knows what he is doing) way to do this is using ldconfig, however, you may do stuff you regret, if you make a mistake here. The safest way to use that command is by using the flags -v -n to make the command verbose and to specify what library directory you need to add.

sudo ldconfig -v -n /usr/local/lib/your-uber-libs

Done. But if you only wanna test something, then rather use your LD_LIBRARY_PATH directly from command line, like this:

LD_LIBRARY_PATH=/usr/local/lib/your-uber-libs ./your_uber_command

Alternatively, add the following to your .bashrc script.

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/your-uber-libs

Now you can run your dynamically linked command.

answered Jan 20, 2017 at 15:45

1 Comment

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<your_lib_path> helped me fix it
3

I copied all the library files from /opt/lib into /usr/lib and the program works now. Thanks for the response.

answered Dec 23, 2010 at 1:05

Comments

2

Try installing the library libxerces-c3.1 as. Use the command mentioned below to install the library.

 sudo apt-get install libxerces-c3.1

This worked like a charm for me.

answered Oct 2, 2014 at 20:45

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.