问题描述
今天在尝试运行make指令时,make中间突然出现了
: not foundld-info.sh: 2:
: not foundld-info.sh: 4:
: not foundld-info.sh: 9:
scripts/build-info.sh: 31: Syntax error: end of file unexpected (expecting "then")
make: *** [Makefile:682: common/build-info.cpp] Error 2
经查阅,该错误是因为在windows系统下使用git clone下载得到文件夹后,上传至linux系统中运行引起的。具体来说,是windows系统下和linux系统下文件结尾字符不一样(一个是CRLF一个是LF)引起的。
解决方案
在clone下来的文件夹下,执行
sudo apt install dos2unix
find -type f -print0 | xargs -0 dos2unix
# 如果想不改变某些文件
find -type f \
-not -path "./<dir_to_exclude>/*" \
-not -path "./<other_dir_to_exclude>/*" \
-print0 | xargs -0 dos2unix
执行完之后再次运行make指令,完美解决。