Specifying dynamic library path to linker at compile time
I would like to compile a binary that doesnot depend on LD_LIBRARY_PATH as this binary will be setuid to owner and used by other users and since setuid doesnot support LD_LIBRARY_PATH making it independent of LD_LIBRARY_PATH would be great.
But I am not able to specify the path of the shared libraries to the linker at compile time. I am using gcc compiler 4.1.2 and on Linux OS Red Hat 5.8. I am using the following compile command where /aaa/bbb/lib is the path of the shared library that is used by the binary waitdb.ORACLE called within the binary simple:
simple.c has nothing but an execvp call to another binary 'waitdb.ORACLE' which uses libuidata.so that is located in /aaa/bbb/lib directory Contents of simple.c are as follows:
But when I run the executable 'simple' I get the following error
On the other hand if I run at the commandline, the export LD_LIBRARY_PATH command before calling the binary it works FINE.
Please advise how I can specify the /aaa/bbb/lib path to the linker at compile time of binary 'simple' so that when 'simple' binary tries to execvp another c binary 'waitdb.ORACLE' binary within it the linker knows where to find the libuidata.so shared library file that waitdb.ORACLE uses (without using the LD_LIBRARY_PATH variable) ?
thanks
Last edited by bartus11; 01-03-2014 at 03:32 PM..
Reason: Please use code tags
-rpath is for the C-program ("simple") itself, not passed to the "exec"ed program.
But you can define the LD_LIBRARY_PATH environment variable in the C-program:
I have a build where I wish to link against and load a specific version of a library and a different version of the same library is installed on the system. I'm using a -L option to point to the version that I wish to link against but gcc still seems to choose the installed version. Is there a way... (4 Replies)
hello
I apologize if my question bothers you
I work on a code developed in C + + which worked well on mac os, this code will help create libraries *.so from *.cc and *.h I used this as flags:CXXFLAGS = -g -O2 -fPIC -Wall -ldl -D_GNU_SOURCE ,CXX := g++ and $(CXX)-shared -o $(LIBNAME) $(CLIBLIB)... (0 Replies)
This so basic that it should work.... Any ideas would be appreciared. Using a number directly in the sqrt allows it to compile.
primrose > cat a.c
#include <stdio.h>
#include <math.h>
int main(void)
{
double abcd=9;
printf("%f\n",sqrt(abcd));
}
primrose > gcc a.c
Undefined first... (2 Replies)
Hi every body
I have a problem like that "Dynamic linker error" message.
I can't load many of programs in sco unix openserver 5.0.6.
I guess this problem appear after my last effort to install "SCO Development System" package.
How can I fix this problem?
would you please help me ? (1 Reply)
Hi,
I created two library libsum.so and libproduct.so. In the libproduct.so is defined function "product" that use function "sum" defined in libsum.so. So libproduct depends on libsum.
In main function I called product function by a dlopen request. Unfortunaly, when I execute program I have an... (5 Replies)
Hi All
Could anyone help in giving a little background to the following runtime error.
/usr/lib/pa20_64/dld.sl: Mmap failed due to errno: 13.
Seen when executing a 64-bit ELF executable.
Thanks
Ed (3 Replies)
Hi,
I wonder how can we override the dynamic library loaded by ld on start up.(dynamic linked application). so that linker uses the new library to find symbols.
Is it possible to do.
Cheers. (4 Replies)
hi, every body. i have in trouble that how to load a dynamic library by hand.
for example, i know how to generate a dynamic library and how to link a dynamic library in makefile.
generate a dynamic library:
add -dy -G behind cc
link a dynamic library in makefile:
add -dy -Bdynamic behind cc... (0 Replies)