1

I am working in Eclipse: Helios Service Release 1 using Eclipse CDT compiling using g++

I have just started to have a go at using Shared Libraries in my projects but have run into a little problem. I have three projects A, B and C. A and B are both Shared Libraries and C is an executable.

Under eclipse I have managed to reference A and B from C and C compiles and runs correctly but when I try and run the generated C program manually outside of Eclipse I get the following error:

"error while loading shared libraries: libA.so: cannot open shared object file: No such file or directory"

I have tried moving A.so B.so and C into the same folder and run C but I get the same error.

Can I get Eclipse to build my project with all the files in the same place and them still run when I move them to a new location?

James
  • 2,609
  • 3
  • 20
  • 27
  • I seem to have the exact same problem, I have libA in the linker, it is also listed under Paths and Symbols --> Library paths. Does the location for libA need to be in the LD_LIBRARY_PATH as well? I am able to compile and run outside of eclipse (from an exterm) – Anu May 06 '11 at 17:43
  • @Anu I found this blog to be very helpful http://dirkraffel.com/2008/06/27/developing-shared-libraries-with-eclipse-cdt/ regarding linking in Eclipse but it didn't really solve my problem when I was exporting. – James May 20 '11 at 07:22

2 Answers2

8

Run ldconfig as root to update the cache - if that still doesn't help, you need to add the path to the file ld.so.conf (just type it in on its own line) or better yet, add the entry to a new file (easier to delete) in directory ld.so.conf.d.

Tim Čas
  • 10,501
  • 3
  • 26
  • 32
3

You just need to set LD_LIBRARY_PATH to include the folder in which the shared libraries are. Something like this: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/lib/

Tom
  • 2,674
  • 1
  • 25
  • 33
v01d
  • 1,457
  • 1
  • 11
  • 22