按照你说的做,为什么会报错如下: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'
时间: 2024-02-22 18:57:28 浏览: 197
PLC模拟量处理
根据你提供的信息,可能是因为在使用 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
```
这样就可以使用管理员权限安装目标了。
阅读全文