LD_LIBRARY_PATH in makefile

At a glance,

1
2
3
dbg:
	set LD_LIBRARY_PATH=/path/to/so
	echo ${LD_LIBRARY_PATH}

Why does the 'echo' command output nothing?

For the dollar sign is not only a key letter in bash, it's also in makefile. And each command line in Makefile shares no environmental variables. So right way is

1
2
3
dbg:
	set LD_LIBRARY_PATH=/path/to/so ; \
	echo $${LD_LIBRARY_PATH}

However, if tst01 needs to load libtst02.so from /path/to/so/,

1
2
dbg:
	set LD_LIBRARY_PATH=/path/to/so ; ./tst01

why does tst01 still report it can't find libtst02.so?

For the 'set' command only lets LD_LIBRARY_PATH variable visible in the bash process where the 'set' is invoked, no spreading in child processes. So final correct script is

1
2
dbg:
	export LD_LIBRARY_PATH=/path/to/so ; ./tst01