views:

13

answers:

1

Hello

gcc 4.4.3 c89 linux

I am using log4c and have placed the inc and lib in the following directories

/home/jeff/projects/gateway/tools/log4c/inc
/home/jeff/projects/gateway/tools/log4c/lib

In my Makefile I have specified the inc and lib path:

INC_PATH = -I tools/log4c/inc
LIB_PATH = -L tools/log4c/lib
LIBS = -llog4c

In my lib directory I have the following shared libraries:

lrwxrwxrwx 1 root root     17 2010-08-26 15:57liblog4c.so -> liblog4c.so.3.1.0
lrwxrwxrwx 1 root root     17 2010-08-26 15:57 liblog4c.so.3 -> liblog4c.so.3.1.0
-rw-r--r-- 1 root root 100180 2010-08-26 15:55 liblog4c.so.3.1.0

I compile my application on my development machine, then copy the binary and tools directory to the test machine

So when I execute binary on the test machine I get the following error:

./app: error while loading shared libraries: liblog4c.so.3: cannot open shared object file: No such file or directory

However, everything works fine on my development machine which has the same directory structure i.e.

dev machine:

/projects/gateway/app
/projects/gateway/tools/log4c/inc
/projects/gateway/tools/log4c/lib

test machine:

/projects/gateway/app
/projects/gateway/tools/log4c/inc
/projects/gateway/tools/log4c/lib

So I am wondering why it can't find it the shared library.

Many thanks for any suggestions,

+2  A: 

/projects/gateway/tools/log4c/lib should either be put to /etc/ld.so.conf (call /sbin/ldconfig after) or to LD_LIBRARY_PATH shell variable so the dynamic linker would know where to search for the required shared library.

See Program Library HOWTO (3.5. Installing and Using a Shared Library) for more info

Dmitry Yudakov
How about using the rpath. The reason I asked is because the user will not know how to configure the system. I will just give them the binaries and the customer just wants to run the application. Thanks.
robUK
yes, using `rpath` is also an option, you'll just have to put valid (for dev, test and production) path of the library. If it's relative, you'll have to run the program from specified directory, where the path will be valid.
Dmitry Yudakov