配置NDK Cygwin .bash_profile:行47: 语法错误: 未预期的文件结尾 syntax error: unexpected end of file 解决

在配置Cygwin的.bash_profile文件时,添加NDK环境变量后遇到行47的语法错误。解决方法是在Cygwin中使用vim编辑或在Windows下直接编辑home目录下的.bash_profile文件。错误是因为回车符不匹配。通过运行`dos2unix -n .bash_profile .bash_profile`来转换文件格式,然后重启Cygwin,问题即可解决。务必避免使用Windows的记事本等编辑器,以免产生格式冲突。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

可以在cygwin中通过vim修改,也可以在windows安装目录中修改 home\<你的用户名>\.bash_profile 文件中最后添加环境变量

NDKROOT=/cygdrive/e/Andriod/develop/android-ndk-r8

export NDKROOT

其中NDK=/cygdrive/<你的盘符>/<android ndk 目录> ,"NDK"这个名字随便起,以后经常用不要太长。

重启cygwin,输入:

cd $NDK

可进入ndk对应目录说明设置OK。

这时候 出现错误

-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: /home/lenovo/.bash_profile: line 47: syntax error: unexpected end of file


在cygwin中输入:dos2unix -n .bash_profile .bash_profile

关闭重新打开cygwin,ok了。所以再一次提醒,不要用window里的记事本或者写字本打开修改,使用UltraEdit不要转化格式,因为在window下和linux中回车符是不相同的。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值