how do I get rid of exporting LD_LIBRARY_PATH (to get rid of " error
while loading shared libraries") while compiling it self in the
Makefile.
how to incorporate some kind of export statement in Makeifle ??
Onkar
Printable View
how do I get rid of exporting LD_LIBRARY_PATH (to get rid of " error
while loading shared libraries") while compiling it self in the
Makefile.
how to incorporate some kind of export statement in Makeifle ??
Onkar
onkar wrote:[color=blue]
> how do I get rid of exporting LD_LIBRARY_PATH (to get rid of " error
> while loading shared libraries") while compiling it self in the
> Makefile.[/color]
In general, you can get rid of LD_LIBRARY_PATH by using -L instead.
You may also want to produce executables that don't need LD_LIBRARY_PATH
set when it is time to run the executable (after build). In order to do
that, try using the -R or -rpath options to pass the path where the library
will actually be installed. Some compilers may require you to put a "-Wl,"
in front of "-rpath" in order to pass the flag through to the linker, so
you may need to use "-Wl,-rpath" instead of just "-rpath" in some cases.
[color=blue]
> how to incorporate some kind of export statement in Makeifle ??[/color]
If by "export statement", you mean that you wish to set an environment
variable in the Makefile, you can do that, but it's not usually a good
way to solve the problem.
- Logan
On Oct 27, 6:21 pm, onkar <onkar....@gmail.com> wrote:[color=blue]
> how do I get rid of exporting LD_LIBRARY_PATH (to get rid of " error
> while loading shared libraries") while compiling it self in the
> Makefile.
>
> how to incorporate some kind of export statement in Makeifle ??
>
> Onkar[/color]
You can add the path to the directory containing libraries by defining
the variable LIBS in the Makefile as shown below:
LIBS=-L/path/to/libdir -lmylib -lm -lpthread
where mylib is the name of your library file
and then use this variable while compliling your program
test:test.o
$(CC) -o test test.o $(LIBS)
or alternatively, to use export statement add the following entry in
your Makefile
LD_LIBRARY_PATH=-L/path/to/libdir
export LD_LIBRARY_PATH
Meenakshi.