Skip to content

Commit

Permalink
更新 windows 查找终端程序的方式
Browse files Browse the repository at this point in the history
  • Loading branch information
Mq-b committed Nov 21, 2024
1 parent 682cf7b commit 4b45e1a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/卢瑟日经/C++ 包管理,编译构建配置等问题.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@ root@Mq-B:/usr/local/include# which cmake
/usr/bin/cmake
```

如果是 window,可以使用 `Get-Command`
如果是 windows,powershell 可以使用 `Get-Command``where.exe`

```powershell
PS C:\Users\Administrator> Get-Command cmake
PS C:\Users\A1387> Get-Command cmake
CommandType Name Version Source
----------- ---- ------- ------
Application cmake.exe 3.30.0.0 D:\CMake\bin\cmake.exe
Application cmake.exe 3.25.2.0 D:\CLion 2023.1.4\bin\cmake\win\x64\bin\cmake.exe
PS C:\Users\A1387> where.exe cmake
D:\CLion 2023.1.4\bin\cmake\win\x64\bin\cmake.exe
```

> CMD 终端直接使用 **`where`** 即可。powershell 终端要强调 `.exe` 是因为 where 这个名字被用作另一个东西的别名了。
## `make`

`make` 是一个自动化构建工具,通常与 Makefile 配合使用。Makefile 中定义了如何编译和链接程序的规则。通过运行 make 命令,make 命令会读取 Makefile,自动执行编译和链接的步骤。基本用法如下:
Expand Down Expand Up @@ -428,9 +433,10 @@ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
不过显然我们无需这样做,我们最好的做法是直接:
```shell
cmake .. -G "Ninja Multi-Config"
cmake .. -G Ninja
cmake --build . --config Debug --parallel
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release --parallel
```
若不指定构建类型,则采用默认构建类型,一般为 Debug
没办法,必须多次运行 `cmake..` 生成需要的 Ninja 文件,这点比较特殊

0 comments on commit 4b45e1a

Please sign in to comment.