M1 Mac编译SDRangel遇x265 arm64未定义符号错误求解决
M1 Mac编译SDRangel时x265链接错误的解决思路
编译时触发的错误信息如下:
-- GIT_EXECUTABLE /opt/local/bin/git -- GIT LIVE REPO VERSION RETRIEVED -- X265 RELEASE VERSION 3.5+68-40e37bce9 -- Detected CXX compiler using -O3 optimization level -- Configuring done -- Generating done -- Build files have been written to: /opt/build/sdrangel/build/external/x265/src/x265-build [ 27%] Performing build step for 'x265' Consolidate compiler generated dependencies of target common [ 45%] Built target common Consolidate compiler generated dependencies of target encoder [ 65%] Built target encoder [ 76%] Built target x265-static [ 77%] Linking CXX shared library libx265.dylib Undefined symbols for architecture arm64: "x265_entropyStateBits", referenced from: _x265_costCoeffNxN_neon in pixel-util.S.o (maybe you meant: _x265_entropyStateBits) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[5]: *** [libx265.206.dylib] Error 1 make[4]: *** [CMakeFiles/x265-shared.dir/all] Error 2 make[3]: *** [all] Error 2 make[2]: *** [external/x265/src/x265-stamp/x265-build] Error 2 make[1]: *** [external/CMakeFiles/x265.dir/all] Error 2 make: *** [all] Error 2
可尝试以下解决思路:
- 禁用NEON优化:错误关联NEON汇编代码
x265_costCoeffNxN_neon,大概率是M1的NEON实现与x265的汇编逻辑不兼容。编译x265时添加CMake参数-DENABLE_NEON=OFF,强制关闭NEON优化,改用通用arm64代码编译。 - 切换x265稳定版本:当前使用的是开发分支版本
3.5+68-40e37bce9,可能存在arm64兼容性bug。切换到x265的官方稳定发布版(如3.5正式版)或最新稳定分支后重新编译。 - 调整符号可见性与链接顺序:
x265_entropyStateBits符号未找到,可能是静态库中该符号未被正确导出,或链接依赖顺序错误。修改x265的CMake配置,确保该符号标记为全局可见,或调整shared库的链接顺序,优先链接common、encoder目标再生成libx265.dylib。 - 使用系统预编译x265库:通过Homebrew或MacPorts安装arm64架构的预编译x265库,然后编译SDRangel时添加参数
-DUSE_EXTERNAL_X265=ON,让项目直接调用系统已安装的库,规避自行编译的兼容性问题。 - 清理缓存后重新编译:可能存在跨架构编译缓存残留(如x86_64编译文件)。删除整个build目录,重新运行CMake时明确指定arm64架构(添加
-DCMAKE_OSX_ARCHITECTURES=arm64参数),再重新执行编译流程。
内容的提问来源于stack exchange,提问作者Peter Betz
相关产品推荐
相关产品推荐

