使用MinGW+NDK-R14b编译Android自定义FFmpeg遇链接错误求助
Hey there, let’s work through this FFmpeg compilation issue you’re hitting for your Android app. That symbolic link error is a common snag when cross-compiling for Android, so here are actionable steps to resolve it:
1. Verify NDK & MinGW Path Configuration
- Avoid spaces in paths: Make sure your NDK and MinGW installation directories don’t have spaces in their paths (e.g., don’t use
C:\Program Files\android-ndk-r14b—move it toC:\android-ndk-r14binstead). Spaces often break command-line tools likelnin MinGW. - Check MinGW’s
lntool: Runln --versionin your MinGW terminal to confirm the tool is installed and working. If it throws an error, reinstall or update your MinGW toolchain to ensure all core utilities are present.
2. Adjust FFmpeg Configure Parameters
Cross-compiling for Android requires precise configure flags—here’s what to tweak:
- Specify target architecture & cross-prefix: For example, if targeting armv7-a, add:
--cross-prefix=arm-linux-androideabi- --target-os=android --arch=arm - Set sysroot correctly: Point to your NDK’s platform-specific sysroot directory (match your target API level and architecture):
--sysroot=$NDK/platforms/android-21/arch-arm - Fix output directory permissions: Ensure the directory specified with
--prefix=/path/to/your/outputexists and has write permissions. Create it manually first if needed:mkdir -p /path/to/your/output - Test with static libraries first: If you don’t strictly need dynamic libraries, add
--disable-shared --enable-staticto skip the symbolic link step entirely. This can help confirm if the issue is isolated to dynamic library generation.
3. Check for Preceding Compilation Errors
The libavutil.so link failure might be a side effect of an earlier error in compiling the libavutil module. Scroll back through your compile log to look for errors like missing headers, invalid compiler flags, or failed object file generation. Fixing those underlying issues will often resolve the symbolic link problem.
4. Workaround: Replace MinGW’s ln Command
If MinGW’s ln is misbehaving, you can override it in the configure step to copy files instead of creating links (note: this is a temporary fix, not ideal for production):
./configure ... LN_S='cp -r'
Start with verifying your paths and configure flags—those are the most frequent causes of this error. If you’re still stuck, sharing your full configure command and the early parts of the compile log will help pinpoint the exact issue!
内容的提问来源于stack exchange,提问作者BW-Eagle

