Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting LD_LIBRARY_PATH from makefile

5,508 views
Skip to first unread message

W. Tucker

unread,
Aug 18, 1999, 3:00:00 AM8/18/99
to
I am trying to build a shared library using the commands described in
the helpful GCC-HOWTO file. When I execute these commands from the
command line, everything works fine. But when I include them inside
a makefile, the LD_LIBRARY_PATH does not get set properly. The exact
command I am using inside the makefile is:

LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH

From the make info document, I understand that I must replace the
single $ with $$. Presumably, some additional quotes or backslashes
are required. Can anyone tell me what changes I need to make? Any
help or advice is greatly appreciated.

Thank you, Wendy Tucker / Symmetric Research


Paul Kimoto

unread,
Aug 18, 1999, 3:00:00 AM8/18/99
to
[Followups reset. This is not a (c.o.l.d.)system issue.]

In article <19990818132138...@ngol05.aol.com>, W. Tucker wrote:
> When I execute these commands from the
> command line, everything works fine. But when I include them inside
> a makefile, the LD_LIBRARY_PATH does not get set properly. The exact
> command I am using inside the makefile is:
>
> LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH

At what stage do you want LD_LIBRARY_PATH to have an effect?
Each makefile rule is executed in a separate shell, and environment
variables are not propagated back from child to parent processes.
If your makefile causes some command like the above to be run,
that rule has no effect on subsequent rules.

Maybe you should change the command where LD_LIBRARY_PATH should
have an effect to
env LD_LIBRARY_PATH=$LD_LIBRARY_PATH my_command and its_arguments
where $LD_LIBRARY_PATH is set appropriately.

--
Paul Kimoto <kim...@lightlink.com>

David T. Blake

unread,
Aug 18, 1999, 3:00:00 AM8/18/99
to
W. Tucker <srac...@aol.com123> wrote:
> I am trying to build a shared library using the commands described in
> the helpful GCC-HOWTO file. When I execute these commands from the

> command line, everything works fine. But when I include them inside
> a makefile, the LD_LIBRARY_PATH does not get set properly. The exact
> command I am using inside the makefile is:
>
> LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH
>

Try
export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}

OR

LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} ; export $LD_LIBRARY_PATH

--
Dave Blake
dbl...@phy.ucsf.edu

Peter Samuelson

unread,
Aug 23, 1999, 3:00:00 AM8/23/99
to
[David T. Blake <dbl...@phy.ucsf.edu>]

> Try
> export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
>
> OR
>
> LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} ; export $LD_LIBRARY_PATH

Bzzzt. This is inside a makefile. As someone already said, each line
of a makefile rule is executed in its own shells, so setting a variable
in one does not affect another.

If you just want LD_LIBRARY_PATH in one rule, use backslashes (\) to
end lines so that you effectively get one rule line:

target: $(TARGET_DEPENDS)
LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) export LD_LIBRARY_PATH \
do_one_command;\
do_another_command;\
do_yet_another;

It's cumbersome for large rules. If on the other hand you want to set
LD_LIBRARY_PATH for the whole makefile, you can set LD_LIBRARY_PATH as
a make variable and then declare the phony target .EXPORT_ALL_VARIABLES
(I think this is a GNU make extension).

--
Peter Samuelson
<sampo.creighton.edu!psamuels>

0 new messages