cmake 提示gcc或交叉编译 broken

本文解决了一个常见的CMake配置问题,即CMake报告GCC无法编译简单的测试程序。通过设置CMake以强制使用特定版本的GCC,并确保环境变量正确指向编译器路径,可以解决这一问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

cmake reports gcc is broken. Where do I start?

-- Check for working C compiler: /usr/bin/gcc -- broken

CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:61 (message): The C compiler "/usr/bin/gcc" is not able to compile a simple test program.

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Could not determine Eclipse version, assuming at least 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
-- Check for working C compiler: /usr/bin/gcc-4.6
-- Check for working C compiler: /usr/bin/gcc-4.6 --  broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
The C compiler "/usr/bin/gcc-4.6" is not able to compile a simple testprogram.


解决


check this Link. i had the same problem. i think the problem is that you need more parameters to compile (like linker-script, flags ...). change your CMakeLists like this and try it again:

INCLUDE(CMakeForceCompiler) 
CMAKE_FORCE_C_COMPILER(gcc GNU)
CMAKE_FORCE_CXX_COMPILER(g++ GNU)

do not forget to set the path to the compiler in your enviroment vars.

参考

http://stackoverflow.com/questions/16594053/cmake-reports-gcc-is-broken-where-do-i-start
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值