Question

One of my binaries requires libfoo.so (which resides in /dir/libfoo) and I can't figure out how to link against it by setting an environment variable. I tried the two following solutions:

export LD_FLAG='-L/dir/libfoo/' export LD_LIBRARY_PATH='-L/dir/libfoo/'

but when I run ldd ./mybin I see libfoo.so.0 => not found among other libs that are found.

I can, however, successfully link when I use this: /lib/ld-linux.so.2 --library-path /dir/libfoo ./mybin

I'm running Ubuntu 13.10 server x86

What am I doing wrong here?

Was it helpful?

Solution

-L is a gcc flag, and gcc is not involved in this process. Just do

export LD_LIBRARY_PATH='/dir/libfoo/'

OTHER TIPS

You have passed -L flag to LD_LIBRARY_PATH this is wrong instead remove -L from LD_LIBRARY_PATH

export LD_LIBRARY_PATH=/dir/libfoo/

Also refer http://man7.org/linux/man-pages/man8/ld.so.8.html for linker/loader specification

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top