Error while loading shared libraries


 
Thread Tools Search this Thread
Top Forums Programming Error while loading shared libraries
# 1  
Old 03-28-2016
Error while loading shared libraries

I am trying to run a C++ program which uses a static library libprun.a. During compilation, I am loading this library file using a environment variable as below.

Code:
LIBDIR =  ${CUSTOM_PATH}/lib

LOADLIBS = $(LIBDIR)/libgqlcomm.a \
	           $(LIBDIR)/libgsml.a \
                   $(LIBDIR)/libprun.a \
                   $(LIBDIR)/libglis.a

I am not getting any errors during compilation or during running the binary in the same environment in which I compiled the binary but I am getting below error when running in a different environment as $CUSTOM_PATH is set to a different path.

I am getting errors only with libprun.a but not with other libraries.

Please suggest

Last edited by Don Cragun; 03-28-2016 at 02:24 AM.. Reason: Add CODE and ICODE tags.
# 2  
Old 03-28-2016
Quote:
Originally Posted by vdivb
I am trying to run a C++ program which uses a static library libprun.a. During compilation, I am loading this library file using a environment variable as below.

Code:
LIBDIR =  ${CUSTOM_PATH}/lib

LOADLIBS = $(LIBDIR)/libgqlcomm.a \
	           $(LIBDIR)/libgsml.a \
                   $(LIBDIR)/libprun.a \
                   $(LIBDIR)/libglis.a

I am not getting any errors during compilation or during running the binary in the same environment in which I compiled the binary but I am getting below error when running in a different environment as $CUSTOM_PATH is set to a different path.

I am getting errors only with libprun.a but not with other libraries.

Please suggest
You haven't given us much to go on here...
  1. What "below error" are you getting?
  2. What different environment are you talking about? Are you talking about just using a different setting for CUSTOM_PATH? Are you talking about different operating systems? ???
  3. How is CUSTOM_PATH set when your code works?
  4. How is CUSTOM_PATH set when your code does not work?
  5. Does the file $CUSTOM_PATH/lib/libprun.a exist in the environment when your code does not work?
  6. What operating system are you using?
# 3  
Old 03-28-2016
1) What "below error" are you getting?
Code:
error while loading shared libraries: /home/dev/lib/libprun.a: cannot open shared object file: No such file or directory.


2) What different environment are you talking about? Are you talking about just using a different setting for CUSTOM_PATH ? Are you talking about different operating systems? ???
Quote:
Yes, Different Setting for CUSTOM_PATH
3) How is CUSTOM_PATH set when your code works?
Quote:
I have set CUSTOM_PATH to /home/dev/ in my environment but this variable may differ in Testing environment for e.g.
My Environment $CUSTOM_PATH=/home/dev/
Testing Environment $CUSTOM_PATH=/home/test/

5) Does the file $CUSTOM_PATH/lib/libprun.a exist in the environment when your code does not work?
Quote:
File exists in below paths
/home/dev/lib/libprun.a (Development)
/home/test/lib/libprun.a (Testing)

Development path is hardcoded after compiling, as /home/dev/lib/libprun.a this is not accessible from Testing Environment, its throwing above error.
5) What operating system are you using?
Quote:
Linux x86_64 x86_64 x86_64 GNU/Linux
# 4  
Old 03-28-2016
By convention, a shared library would have the extension .so instead of .a.

What command do you use to build your program (in both environments)?

What output do you get from the commands:
Code:
for dir in /home/test/lib /home/dev/lib
do	echo "$dir:"
	ls -ld "$dir/"libprun.*
	file "$dir/"libprun.*
done

# 5  
Old 03-28-2016
Here is the output which I am getting for the above piece of code.

Quote:
/home/test/lib:
-rwxr-xr-x 1 divcst1 generic 44345 Mar 7 13:26 /home/test/lib/libprun.a
/home/test/lib/libprun.a: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
/home/dev/lib:
ls: cannot access /home/dev/lib/libprun.*: No such file or directory
/home/dev/lib/libprun.*: cannot open `/home/dev/lib/libprun.*' (No such file or directory)
# 6  
Old 03-29-2016
You didn't my answer question about what command(s) you use to build your program, but it seems pretty obvious to me that you either need to:
  1. copy or link /home/test/lib/libprun.a to /home/dev/lib/libprun.a or
  2. change the way you build your program so that when it runs it loads /home/test/lib/libprun.a instead of /home/dev/lib/libprun.a.
# 7  
Old 03-29-2016
Seems like all you need to do is modify the value of the CUSTOM_PATH environment variable...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Error while loading shared libraries

Hello, I am trying to run a program from my local account and receive the following error: /local/app: error while loading shared libraries: libtiff.so.3: cannot open shared object file: No such file or directory On the root account (which I DO NOT have access to), I see that libtiff.so.4... (3 Replies)
Discussion started by: bphqk3
3 Replies

2. Red Hat

/usr/bin/rhgb-client -- error while loading shared libraries: libpopt.so.0

Hi All, I have RHEL 5 installed in my system. Something must has happened because when i reboot the server, it came with many error.. /usr/bin/rhgb-client -- error while loading shared libraries: libpopt.so.0. Can't open shared object files. No such file/directory It finnaly ends with the... (6 Replies)
Discussion started by: IgnitedMind
6 Replies

3. Linux

xz: error while loading shared libraries: liblzma.so.5

Help! I'm busy working on MySQL replication for the site and trying to unzip this bind-geodns xz file on Linux (ubuntu) and am having some problems. http://distro.ibiblio.org/pub/linux/distributions/archlinux/community/os/i686/bind-geodns-9.4.1-4-i686.pkg.tar.xz Could anyone kindly unzip... (4 Replies)
Discussion started by: Neo
4 Replies

4. Ubuntu

error while loading shared libraries: libxerces-c.so.28

Hi, Can any one help me ,how to rectify the below problem?........ "error while loading shared libraries: libxerces-c.so.28: cannot open shared object file: No such file or directory" Im using "ubuntu 10.04" (64 bit) (0 Replies)
Discussion started by: kavi.mogu
0 Replies

5. Red Hat

RHEL5 reboot - error loading shared library

Hi All, I have RHEL 5 installed in my system. Something must has happened because when i reboot the server, it came with many error.. /usr/bin/rhgb-client -- error while loading shared libraries: libpopt.so.0. Can't open shared object files. No such file/directory It finnaly ends with the... (0 Replies)
Discussion started by: c00kie88
0 Replies

6. Linux

Shared Libraries

How do i make a library shared say i have a library a.so which i have just compiled. I want to make it shared how do i make it Next Queation is what is the difference between a.so.0 a.so.1 a.so.2 & a.so :rolleyes: (1 Reply)
Discussion started by: wojtyla
1 Replies

7. HP-UX

Loading shared Libraries dynamically

HI, I am dynamically loading shared libraries using shl_load(). There are multiple processes (50 or more) which loads the same shared library. Will Unix internally load only one copy of the shared library or it will load multiple copies. Can I have memory issues if this is done. Thanks,... (1 Reply)
Discussion started by: Debasisb2002
1 Replies

8. UNIX for Dummies Questions & Answers

Clarification about shared Libraries

I have a doubt about the shared libraries. Where do you set the path for the shared libaries, for the dynamic loader to locate. Any suggestion would be of great help. thanks (3 Replies)
Discussion started by: ramkumar_gr
3 Replies

9. Programming

shared libraries

I am compiling code which produces .a and .la libraries. How can I produce .so libraries? I know that gcc -shared does but how? (2 Replies)
Discussion started by: thalex
2 Replies

10. Programming

Shared libraries

Hello everybody, I am having major problems at the moment with shared libraries and I have to little knowledge of them to solve them. So please, please help me :) Ok this is the problem: I have a library A, which uses B and C, and C uses again D. If I try to run A as plugin in apache,... (0 Replies)
Discussion started by: Micky
0 Replies
Login or Register to Ask a Question