跳转到内容
新建笔记

[CMake] "D:/program/gcc-arm-none-eabi/bin/arm-none-eabi-gcc.exe"[CMake] is not able to compile

终端窗口
[main] 正在配置项目: imx8_ad7606
[driver] 删除 c:/Users/mtxl/Desktop/imx8_ad7606/build/CMakeCache.txt
[driver] 删除 c:%5CUsers%5Cmtxl%5CDesktop%5Cimx8_ad7606%5Cbuild%5CCMakeFiles
[proc] 正在执行命令: D:\program\cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=D:\program\gcc-arm-none-eabi\bin\arm-none-eabi-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=D:\program\gcc-arm-none-eabi\bin\arm-none-eabi-g++.exe --no-warn-unused-cli -S C:/Users/mtxl/Desktop/imx8_ad7606 -B c:/Users/mtxl/Desktop/imx8_ad7606/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] -- The C compiler identification is GNU 13.3.1
[cmake] -- The CXX compiler identification is GNU 13.3.1
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - failed
[cmake] -- Check for working C compiler: D:/program/gcc-arm-none-eabi/bin/arm-none-eabi-gcc.exe
[cmake] -- Check for working C compiler: D:/program/gcc-arm-none-eabi/bin/arm-none-eabi-gcc.exe - broken
[cmake] CMake Error at D:/program/cmake/share/cmake-4.1/Modules/CMakeTestCCompiler.cmake:67 (message):
[cmake] The C compiler
[cmake]
[cmake] "D:/program/gcc-arm-none-eabi/bin/arm-none-eabi-gcc.exe"
[cmake]
[cmake] is not able to compile a simple test program.
[cmake]
[cmake] It fails with the following output:
[cmake]
[cmake] Change Dir: 'C:/Users/mtxl/Desktop/imx8_ad7606/build/CMakeFiles/CMakeScratch/TryCompile-q51sv8'
[cmake]
[cmake] Run Build Command(s): D:/programXilinx/2025.1/Vivado/bin/ninja.exe -v cmTC_f190c
[cmake] [1/2] D:\program\gcc-arm-none-eabi\bin\arm-none-eabi-gcc.exe -std=gnu11 -o CMakeFiles/cmTC_f190c.dir/testCCompiler.c.obj -c C:/Users/mtxl/Desktop/imx8_ad7606/build/CMakeFiles/CMakeScratch/TryCompile-q51sv8/testCCompiler.c
[cmake] [2/2] C:\WINDOWS\system32\cmd.exe /C "cd . && D:\program\gcc-arm-none-eabi\bin\arm-none-eabi-gcc.exe CMakeFiles/cmTC_f190c.dir/testCCompiler.c.obj -o cmTC_f190c.exe -Wl,--out-implib,libcmTC_f190c.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
[cmake] FAILED: cmTC_f190c.exe
[cmake] C:\WINDOWS\system32\cmd.exe /C "cd . && D:\program\gcc-arm-none-eabi\bin\arm-none-eabi-gcc.exe CMakeFiles/cmTC_f190c.dir/testCCompiler.c.obj -o cmTC_f190c.exe -Wl,--out-implib,libcmTC_f190c.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
[cmake] D:/program/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: unrecognized option '--major-image-version'
[cmake] D:/program/gcc-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: use the --help option for usage information
[cmake] collect2.exe: error: ld returned 1 exit status
[cmake] ninja: build stopped: subcommand failed.
[cmake]
[cmake]
[cmake]
[cmake]
[cmake]
[cmake] CMake will not be able to correctly generate this project.
[cmake] Call Stack (most recent call first):
[cmake] CMakeLists.txt:28 (project)
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
[proc] 命令“D:\program\cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=D:\program\gcc-arm-none-eabi\bin\arm-none-eabi-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=D:\program\gcc-arm-none-eabi\bin\arm-none-eabi-g++.exe --no-warn-unused-cli -S C:/Users/mtxl/Desktop/imx8_ad7606 -B c:/Users/mtxl/Desktop/imx8_ad7606/build -G Ninja”已退出,代码为 1

CMake 检测到你使用的是 arm-none-eabi-gcc 交叉编译器,但它仍然尝试使用 Windows 平台的链接器参数。

解决方法:

settings.json
{
"cmake.configureSettings": {
"CMAKE_TOOLCHAIN_FILE": "${workspaceFolder}/cmake/gcc-arm-none-eabi.cmake"
}
}

来源:CSDN 原文,首次发布于 2026-01-16。