为什么可执行文件无法接收 Makefile 中导出的变量?
我有一个 makefile,其中导出将由可执行文件接收的变量,但令人惊讶的是可执行文件没有接收导出的值。
请帮我。
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 程序),它应该接收导出的变量,但它没有接收。请帮我。
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.
Please help me.
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
is an executable (C program) which should receive the exported variables, but it is not getting. Please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我没有记错的话,Makefile 中的每一行都是一个单独的 shell 进程。因此 shell 导出不适用于多个进程:一种方法是将它们放入一行:
或用 '\' 进行换行转义,
就像 ENV 变量可用于 ./time-interval-measrument
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:
or line-break-escaped with '\'
Like that the ENV-variables are available to ./time-interval-measrument
我问过类似的问题,但情况不完全相同
如何实现 makefile 共享变量
理想情况下,导出的变量应该已传递到子进程,我想知道你的子shell是否与父进程相同。
尝试以下操作 -
导出 EF_ERRTRACK_START=3;导出 EF_ERRTRACK_END=5; ./时间间隔测量测试
I had asked for a similar question, but its not the exact same scenario
how to implement makefile shared variable
Ideally your exported variables should have passed on to the child process, I wonder if your child shell is same as parent.
Try following -
export EF_ERRTRACK_START=3; export EF_ERRTRACK_END=5; ./time-interval-measurement-test