ubuntu下的错误解决 eclipse cmake 错误

时间:2024-03-16 17:50:41


CMake Error:
  The detected version of Ninja () is less than the version of Ninja required
  by CMake (1.3).

​CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

 

解决方法:

主要原因是ninja没有正确安装。

https://ninja-build.org/

可以自己编译,也可以直接用二进制文件。

新建一个cmake 工程

ubuntu下的错误解决 eclipse cmake 错误

ubuntu下的错误解决 eclipse cmake 错误

 

CMakeCache.txt 文件中有一行:

CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/ninja

将jinja文件拷贝到/usr/bin/文件目录下。

编译输出:

Building in: /home/q/eclipse-workspace/bb/build/default
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /home/q/eclipse-workspace/bb
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- 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 using: Ninja
-- Check for working CXX compiler using: Ninja -- 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/q/eclipse-workspace/bb/build/default
cmake --build . -- -v
[1/2] /usr/bin/c++     -O3 -DNDEBUG -MMD -MT CMakeFiles/bb.dir/bb.cpp.o -MF CMakeFiles/bb.dir/bb.cpp.o.d -o CMakeFiles/bb.dir/bb.cpp.o -c ../../bb.cpp
[2/2] : && /usr/bin/c++   -O3 -DNDEBUG   CMakeFiles/bb.dir/bb.cpp.o  -o bb  -rdynamic && :
Build complete (0 errors, 0 warnings): /home/q/eclipse-workspace/bb/build/default