我有以下makefile(代码段)
INSTALL_LIB = /usr/local/lib
...
install:
@echo libs are at $(INSTALL_LIB)
LD_LIBRARY_PATH=$(INSTALL_LIB)
@echo libs will be installed at $(LD_LIBRARY_PATH)
但是,make install
会导致:
lib path is /usr/local/lib
LD_LIBRARY_PATH=/usr/local/lib
libs will be installed at
获得相同的结果
export LD_LIBRARY_PATH=$(INSTALL_LIB)
或
export LD_LIBRARY_PATH="$(INSTALL_LIB)"
我确信我遗漏了一些关于如何制作的基本信息,但是在网上搜索并没有产生任何具体的结果。
让我更加困惑的是
LD_LIBRARY_PATH= $(INSTALL_LIB)
结果
/bin/sh: /usr/local/lib: is a directory
和
LD_LIBRARY_PATH = $(INSTALL_LIB)
结果
/bin/sh: LD_LIBRARY_PATH: command not found
--------------编辑-----------------
根据建议,我将makefile更改为:
INSTALL_LIB = /usr/local/lib
...
install:
@echo libs are at $(INSTALL_LIB)
@LD_LIBRARY_PATH=$(INSTALL_LIB);\
echo libs will be installed at $$LD_LIBRARY_PATH
并且输出变为预期:
lib path is /usr/local/lib
libs will be installed at /usr/local/lib
这解决了这个问题。 (但是,我仍然想知道如何在makefile实例之外,例如在命令行上使LD_LIBRARY_PATH
可用)
答案 0 :(得分:4)
配方的每个行都在一个单独的shell中执行,所以行
LD_LIBRARY_PATH=$(INSTALL_LIB)
仅对其运行的shell有效。您需要在shell命令中设置LD_LIBRARY_PATH
的值,但是您需要向Makefile
显示更多关于如何执行此操作的建议。