为什么Makefile中的导出变量不能被可执行文件接收? [英] Why exported variables in Makefile is not received by executable?

查看:84
本文介绍了为什么Makefile中的导出变量不能被可执行文件接收?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个makefile,我在其中导出将由可执行文件接收的变量,但令人惊讶的是,可执行文件未接收导出的值.

I have a makefile, where i am exporting variables which will be received by an executable, but surprisingly the executable is not receiving the exported values.

请帮助我.

31 test:
32         @ echo
33         @ echo "Testing Electric Fence."
34         @ echo "After the last test, it should print that the test has PASSED."
35         ./eftest
36         ./tstheap 3072
37         export EF_ERRTRACK_START=3
38         export EF_ERRTRACK_END=5
39         ./time-interval-measurement-test
40         @ echo
41         @ echo "Electric Fence confidence test PASSED." 
42         @ echo

time-interval-measurement-test是可执行文件(C程序),应接收导出的变量,但没有获取.请帮助我.

time-interval-measurement-test is an executable (C program) which should receive the exported variables, but it is not getting. Please help me.

推荐答案

如果我没有记错的话,Makefile中的每一行都是一个单独的shell进程.因此,shell导出不适用于多个进程:一种方法是将它们放在一行中:

If I'm not mistaken each line in a Makefile is a separate shell-process. So shell-export does not work for several processes: One way to do it is to put them into one line:

test:
         @ echo
         @ echo "Testing Electric Fence."
         @ echo "After the last test, it should print that the test has PASSED."
         ./eftest
         ./tstheap 3072
         EF_ERRTRACK_START=3 EF_ERRTRACK_END=5 ./time-interval-measurement-test
         @ echo
         @ echo "Electric Fence confidence test PASSED." 
         @ echo

或用'\'换行的换行符

or line-break-escaped with '\'

test:
        [..]
        EF_ERRTRACK_START=3 \
        EF_ERRTRACK_END=5 \
        ./time-interval-measurement-test

就像ENV变量可用于./time-interval-measrument

Like that the ENV-variables are available to ./time-interval-measrument

这篇关于为什么Makefile中的导出变量不能被可执行文件接收?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆