Linux Makefile and symbolic links

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7027740/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 05:39:28  来源:igfitidea点击:

Makefile and symbolic links

linuxmakefileln

提问by hanno

I'm experiencing a strange problem with a makefile. I simply want to set a symbolic link in the makefile but get an error message on one machine (Linux 2.6.18-238.12.1.el5)

I'm experiencing a strange problem with a makefile. I simply want to set a symbolic link in the makefile but get an error message on one machine (Linux 2.6.18-238.12.1.el5)

make: execvp: ln: Too many levels of symbolic links

It works perfectly fine on my MacBook. It also works fine if I execute the same command in the shell. What could go wrong? Are there any environment variables important for ln?

It works perfectly fine on my MacBook. It also works fine if I execute the same command in the shell. What could go wrong? Are there any environment variables important for ln?

采纳答案by Nemo

The execvpin the error message is the key, I think. I believe it is saying there are too many levels of symbolic links while trying to locate the ln command itself.

The execvpin the error message is the key, I think. I believe it is saying there are too many levels of symbolic links while trying to locate the ln command itself.

Example:

Example:

all:
    ln -nsf /tmp/foo /tmp/foo
    /tmp/foo/ln x y

Running "make" with this Makefile errors out with:

Running "make" with this Makefile errors out with:

make: execvp: /tmp/foo/ln: Too many levels of symbolic links

So, how is your Makefile invoking ln, exactly? What is in your PATHetc.?

So, how is your Makefile invoking ln, exactly? What is in your PATHetc.?

[update]

[update]

I bet the Makefile is messing up your PATH. Here is a Makefile that reproduces your exact error message:

I bet the Makefile is messing up your PATH. Here is a Makefile that reproduces your exact error message:

PATH=/tmp/foo

all:
    /bin/ln -nsf /tmp/foo /tmp/foo
    ln x y