-bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory

[code lang="shell"]
./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
[/code]

-bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory

今天在编译 jpeg-6b 的时候,出现一行这样的错误,

看见 ^M 就联想到了 Window 下的 dos 格式
[code lang="shell"]
vim ./configure
[/code]

:set ff
fileformat=dos

我X,果然是!

这是 Linux 和 Windows 换行符的差异导致的,
说明 configure 这个文件是作者在 Window 写的,并且没有将文件格式设置成 unix 格式(一般的编辑器都有这项设置),
所以在 Linux 打开时,在每行后面会加个 ctrl+m 就是 ^M
所以 /bin/sh 就变成了 /bin/sh^M
所以脚本就不能运行了
[code lang="shell"]dos2unix configure[/code]
我把文件格式转换之后,就OK了!

如果你的系统不支持 dos2unix,你也可以
[code lang="shell"]
vim ./configure
[/code]

:set ff=unix
:wq

Related post

微信公众号:程序员到架构师

最新文章

Return Top