Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux LD_LIBRARY_PATH:仅当启动调用也在同一行时才起作用_Linux_Makefile_Shared Libraries - Fatal编程技术网

Linux LD_LIBRARY_PATH:仅当启动调用也在同一行时才起作用

Linux LD_LIBRARY_PATH:仅当启动调用也在同一行时才起作用,linux,makefile,shared-libraries,Linux,Makefile,Shared Libraries,我可以使用makefile中的以下命令启动程序: LD_LIBRARY_PATH=$(CUDAHOME)/lib64:$(LIBHOME)/boost_1_54_0/stage/lib mpiloader -np 2 ./program 当我切换到同一命令的两行版本时(任何人似乎都这么做) 不再找到boost中的库: ./program: error while loading shared libraries: libboost_chrono.so.1.54.0: cannot open s

我可以使用makefile中的以下命令启动程序:

LD_LIBRARY_PATH=$(CUDAHOME)/lib64:$(LIBHOME)/boost_1_54_0/stage/lib mpiloader -np 2 ./program
当我切换到同一命令的两行版本时(任何人似乎都这么做)

不再找到boost中的库:

./program: error while loading shared libraries: libboost_chrono.so.1.54.0: cannot open shared object file: No such file or directory

据我所知,一行和两行版本的启动代码应该完全相同。那么这里怎么了?

默认情况下,Makefile中的每个配方行都会调用一个新的shell实例,因此您的
导出只在第一行执行完毕之前有效

使用GNU make,您可以通过定义特殊目标来更改此行为:

.ONESHELL:
all:
    @export foo=bar
    @echo $$foo
输出

bar
bar