When I tried to compile the FFmpeg source code with Ubuntu, I needed to write a build_android.sh file. At that time, I edited it in the win10 system, and then copied it to the virtual machine. After running, it will directly report an error:
/bin/bash^M: interpreter error: No such file or directory
Error: bash: ./build_android.sh: /bin/sh^M: interpreter error: No such file or directory
After searching the information, I found the reason:
1. dos / windows and unix / linux caused by the encoding problem of newline format, dos / windows "\n\r" means newline, unix / linux "\n" means newline
2. When editing under win, the end of the newline is \n\r, but under linux it is \n, so there will be extra \r
Solution:
Execute the following command
sed -i 's/\r$//' build_android.sh
Will replace the \r in build_android.sh with a blank, compile again, success!
Another small problem is that when executing the build_android.sh written by myself, there may be a permission problem, you can add executable attributes to the file:
chmod +x build_android.sh