MSYS2+MinGW-w64编译FMIL库遇cmake.exe: Bad address错误
编译FMIL 2.0.3库时遇到
cmake.exe: Bad address错误 使用MSYS2和mingw-w64-x86_64-cmake从源码编译FMIL 2.0.3库,执行make时触发cmake.exe: Bad address错误,具体报错如下:
$ make [ 1%] Built target c99snprintf [ 7%] Built target jmutils [ 8%] Performing dependent_reconfigure step for 'expatex' => /bin/sh: line 1: /C/msys64/mingw64/bin/cmake.exe: Bad address <============================================== make[2]: *** [CMakeFiles/expatex.dir/build.make:101: ExpatEx/stamp/expatex-dependent_reconfigure] Error 126 make[1]: *** [CMakeFiles/Makefile2:257: CMakeFiles/expatex.dir/all] Error 2 make: *** [Makefile:146: all] Error 2
前置配置步骤(无报错)
此前执行cmake配置命令未出现异常:
$ cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DFMILIB_BUILD_STATIC_LIB=OFF -DFMILIB_BUILD_SHARED_LIB=ON ..
当前环境信息
使用全新安装的msys2-x86_64-20230318版本,已执行全量更新,相关工具版本及路径如下:
$ pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc make $ cmake --version cmake version 3.26.3 CMake suite maintained and supported by Kitware (kitware.com/cmake). $ which cmake /mingw64/bin/cmake $ make --version GNU Make 4.4.1 Built for x86_64-pc-msys $ which make /usr/bin/make $ gcc --version gcc.exe (Rev10, Built by MSYS2 project) 12.2.0 $ which gcc /mingw64/bin/gcc $ pacman -Syuu :: Synchronizing package databases... clangarm64 is up to date mingw32 is up to date mingw64 is up to date ucrt64 is up to date clang32 is up to date clang64 is up to date msys is up to date :: Starting core system upgrade... there is nothing to do :: Starting full system upgrade... there is nothing to do
已排查/尝试的动作
- 确认编译路径无空格
- 未使用Visual Studio环境
- 已重装并更新cmake、make、gcc至最新版本
- 通过
msys2_shell.cmd -mingw64 -use-full-path启动shell,问题未改善 - 检查Windows事件日志、微软Defender日志,无相关错误记录
- 使用Ninja替代make可正常编译,但希望解决make环境下cmake崩溃的问题,需进一步分析或解决该错误。
内容的提问来源于stack exchange,提问作者HugoRune
相关产品推荐
相关产品推荐

