ubuntu cmake..中出现Could not find cmake module file Error required internal CMake variable not set,的问题

在Ubuntu上使用CMake构建一个简单的HelloWorld工程时,遇到'Could not find cmake module file'错误。尝试了通过yum安装CMake和解决版本问题,但问题仍未解决。最终发现错误源头在于CMakeLists.txt文件中project()命令后不应有空格,移除空格后,CMake配置成功。

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

ubuntu cmake…中出现的问题

在写一个helloworld的小工程,然后cmakelists如下

cmake_minimum_required( VERSION 2.8)
project (hello world)
add_executable(helloworld main.cpp)

执行cmake…
结果出现报错

CMake Error: Could not find cmake module file: CMakeDetermineworldCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_world_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_world_COMPILER
CMake Error: Could not find cmake module file: /home/south/code/123/CMakeFiles/3.16.3/CMakeworldCompiler.cmake
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_world_COMPILER could be found.

  Tell CMake where to find the compiler by setting the CMake cache entry
  CMAKE_world_COMPILER to the full path to the compiler, or to the compiler
  name if it is in the PATH.


CMake Error: Could not find cmake module file: CMakeworldInformation.cmake
CMake Error: CMAKE_world_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "/home/south/code/123/CMakeFiles/CMakeOutput.log".

上网找了很多的相关问题,有说需要用yum安装cmake的还有说是版本问题的
一一试过都不行,最后发现问题出在project()里面不能有空格。。。。。。。。

空格删掉最终cmake …成功

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/south/code/123

任重而道远啊…

评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值