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.

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?

1) What "below error" are you getting?

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? ???

3) How is CUSTOM_PATH set when your code works?

5) Does the file $CUSTOM_PATH/lib/libprun.a exist in the environment when your code does not work?

5) What operating system are you using?

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:

for dir in /home/test/lib /home/dev/lib
do	echo "$dir:"
	ls -ld "$dir/"libprun.*
	file "$dir/"libprun.*
done

Here is the output which I am getting for the above piece of code.

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 .

Seems like all you need to do is modify the value of the CUSTOM_PATH environment variable...

Hi,

Attaching makefile for reference.

$INFINYS_ROOT in above makefile is different across different environments.

Thank you