czj@czj-virtual-machine:~/build$ cmake .. -G Ninia CMake Error: Could not create named generator Ninia Generators * Unix Makefiles = Generates standard UNIX makefiles. Green Hills MULTI = Generates Green Hills MULTI files (experimental, work-in-progress). Ninja = Generates build.ninja files. Watcom WMake = Generates Watcom WMake makefiles. CodeBlocks - Ninja = Generates CodeBlocks project files. CodeBlocks - Unix Makefiles = Generates CodeBlocks project files. CodeLite - Ninja = Generates CodeLite project files. CodeLite - Unix Makefiles = Generates CodeLite project files. Sublime Text 2 - Ninja = Generates Sublime Text 2 project files. Sublime Text 2 - Unix Makefiles = Generates Sublime Text 2 project files. Kate - Ninja = Generates Kate project files. Kate - Unix Makefiles = Generates Kate project files. Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files. Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
时间: 2024-02-14 21:04:34 浏览: 132
你的命令有一个拼写错误,应该是 `-G Ninja` 而不是 `-G Ninia`。请重新输入命令:
```
cmake .. -G Ninja
```
这样就能够正确地生成 Ninja build files 了。
相关问题
执行到第三部报错如下,怎么解决呢:czj@czj-virtual-machine:~$ mkdir build czj@czj-virtual-machine:~$ cd build czj@czj-virtual-machine:~/build$ cmake .. -G Ninja CMake Error: The source directory "/home/czj" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.
这个错误提示表明CMake无法在当前目录下找到CMakeLists.txt文件。你可以检查一下当前目录是否正确,或者是否已经将你的项目放在该目录下。如果是,你可以尝试指定正确的路径,例如:
```
cmake /path/to/your/project -G Ninja
```
或者你可以在当前目录下创建一个空的CMakeLists.txt文件,这样CMake就能够找到该文件并开始构建过程了。
按照你说的做,为什么会报错如下:czj@czj-virtual-machine:~/build$ cmake .. -G Ninja CMake Warning (dev) in CMakeLists.txt: No project() command is present. The top-level CMakeLists.txt file must contain a literal, direct call to the project() command. Add a line of code such as project(ProjectName) near the top of the file, but after cmake_minimum_required(). CMake is pretending there is a "project(Project)" command on the first line. This warning is for project developers. Use -Wno-dev to suppress it. -- The C compiler identification is GNU 9.4.0 -- The CXX compiler identification is GNU 9.4.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/czj/build czj@czj-virtual-machine:~/build$ ninja ninja: no work to do. czj@czj-virtual-machine:~/build$ sudo ninja install [sudo] czj 的密码: ninja: error: unknown target 'install'
根据你提供的信息,可能是因为在使用 Ninja 构建系统时,没有配置 install 目标。你可以检查一下 CMakeLists.txt 文件中是否添加了 install 目标。如果没有,你可以添加以下代码:
```
install(TARGETS <target_name>
DESTINATION <destination_folder>)
```
其中,`<target_name>` 是要安装的目标名称,`<destination_folder>` 是安装目标的路径。例如:
```
install(TARGETS my_app
DESTINATION bin)
```
表示将 `my_app` 应用程序安装到 `/usr/local/bin` 目录下。
如果你已经添加了 install 目标,那么可能是因为你没有使用 sudo 权限运行 `ninja install` 命令。你可以使用以下命令来运行:
```
sudo ninja install
```
这样就可以使用管理员权限安装目标了。
阅读全文