如何使用 MSYS 中的 GCC 而不是我在 PowerShell 7 上使用的 GCC

问题描述 投票:0回答:1

我已经使用

pacman -S --needed base-devel mingw-w64-x86_64-toolchain
安装了带有 MSYS2 的 gcc,当我在 MSYS2 MIGW64
 上执行 
gcc --version

时,得到了以下输出
gcc.exe (Rev7, Built by MSYS2 project) 13.1.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

但是在 powershell 上执行时得到以下输出

gcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

我想在我的 powershell 内的 MSYS2 上使用 GCC,我该怎么做?

gcc mingw-w64 msys2
1个回答
0
投票

gcc.exe
变量的开头添加所需
PATH
的位置。

在 PowerShell 中,这看起来像这样:

$env:Path = 'C:\mingw64\bin;' + $env:Path
gcc --version
© www.soinside.com 2019 - 2024. All rights reserved.