/usr/local/bin:/usr/bin: 到 $PATH 的末尾而不是顶部

发布于 2025-01-03 06:08:08 字数 2025 浏览 1 评论 0原文

我正在尝试使用 MSVC 链接器进行 ICU 代码。但是,启动 Cygwin 会将 /usr/local/bin 和 /usr/bin 放在路径前面,导致 link.exe 始终调用 Cygwin 版本,而不是 MSVC 版本。我该如何解决这个配置问题?目前,我启动 VS 命令提示符,然后启动 cygwin.bat。

/usr/local/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Microsoft F#/v4.0:/cygdr ive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VSTSDB/部署:/cygdrive/c /Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/BIN:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/工具:/cygdrive/c/Windows/Microsoft.NET/F ramework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c /Program Files (x86)/Microsoft Visual Studio 10.0/VC/VCPackages:/cygdrive/c/Program Files (x86)/HTML 帮助研讨会:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/团队工具/性能工具:/cygdrive/c/Program Files (x86)/Mic rosoft SDKs/Windows/v7.0A/bin/NETFX 4.0 工具:/cygdrive/c/Program 文件 (x86)/Microsoft SDKs/Windows/v7.0A/bin:/cygdrive/c/Program 文件/公用文件/Microsoft 共享/Windows 直播:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c /Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygd rive/c/程序文件 (x86)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL 服务器/100/工具/Binn:/cygdrive/c/Program Files/Microsoft SQL 服务器/100/DTS/Binn:/cygdrive/c/Program Files (x86)/Microsoft ASP.NET/ASP.NET 网页/v1.0:/cygdrive/c/Program 文件/TortoiseHg:/cygdrive/c/Program Files (x86)/GtkSharp/2.12/bin:/cygdrive/c/Users/tim/AppData/Roaming/npm:/cygdrive/c/P rogram 文件 (x86)/nodejs:/cygdrive/c/Program Files (x86)/Common 文件/Intuit/QB POSSDKRuntime:/cygdrive/c/Program Files (x86)/Git/cmd

ICU 告诉我

确保 PATH 的顺序是 MSVC、Cygwin、然后是其他 路径。配置脚本需要Cygwin中的某些工具(例如grep)。

更新。我的 cygwin.bat 如下所示:

@回声关闭

C: chdir C:\cygwin\bin

bash --login -i

不是很有帮助。

I'm trying to ICU code using the MSVC linker. However, launching Cygwin places the /usr/local/bin and /usr/bin in front of the path, causing link.exe to always call the Cygwin version, instead of the MSVC version. How can I fix this configuration issue? Currently, I launch the VS command prompt, then launch cygwin.bat.

/usr/local/bin:/usr/bin:/cygdrive/c/Program Files (x86)/Microsoft
F#/v4.0:/cygdr ive/c/Program Files (x86)/Microsoft Visual Studio
10.0/VSTSDB/Deploy:/cygdrive/c /Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Progra m Files (x86)/Microsoft
Visual Studio 10.0/VC/BIN:/cygdrive/c/Program Files (x86 )/Microsoft
Visual Studio 10.0/Common7/Tools:/cygdrive/c/Windows/Microsoft.NET/F
ramework/v4.0.30319:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c /Program Files (x86)/Microsoft Visual Studio
10.0/VC/VCPackages:/cygdrive/c/Prog ram Files (x86)/HTML Help Workshop:/cygdrive/c/Program Files (x86)/Microsoft Vis ual Studio
10.0/Team Tools/Performance Tools:/cygdrive/c/Program Files (x86)/Mic rosoft SDKs/Windows/v7.0A/bin/NETFX 4.0 Tools:/cygdrive/c/Program
Files (x86)/Mi crosoft SDKs/Windows/v7.0A/bin:/cygdrive/c/Program
Files/Common Files/Microsoft Shared/Windows
Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c
/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygd
rive/c/Program Files (x86)/Microsoft SQL
Server/100/Tools/Binn:/cygdrive/c/Progr am Files/Microsoft SQL
Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL
Server/100/DTS/Binn:/cygdrive/c/Program Files (x86)/Microsoft
ASP.NET/ASP.N ET Web Pages/v1.0:/cygdrive/c/Program
Files/TortoiseHg:/cygdrive/c/Program Files
(x86)/GtkSharp/2.12/bin:/cygdrive/c/Users/tim/AppData/Roaming/npm:/cygdrive/c/P
rogram Files (x86)/nodejs:/cygdrive/c/Program Files (x86)/Common
Files/Intuit/QB POSSDKRuntime:/cygdrive/c/Program Files (x86)/Git/cmd

ICU tells me to

Ensure that the order of the PATH is MSVC, Cygwin, and then other
PATHs. The configure script needs certain tools in Cygwin (e.g. grep).

Update. My cygwin.bat looks like this:

@echo off

C: chdir C:\cygwin\bin

bash --login -i

Not very helpful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅听莫相离 2025-01-10 06:08:08

对于 Cygwin 的默认安装,PATH 设置为 /etc/profile。您可以修改 PATH,以便附加 /usr/local/bin:/usr/bin 而不是前置。

# PATH="/usr/local/bin:/usr/bin:${PATH}"
PATH="${PATH}:/usr/local/bin:/usr/bin/"

导致:

Setting environment for using Microsoft Visual Studio 2010 x86 tools.

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>c:\cygwin\cygwin.bat

tim@xxx ~
$ printenv PATH
/cygdrive/c/Program Files (x86)/Microsoft F#/v4.0:/cygdrive/c/Program Files (x86
)/Microsoft Visual Studio 10.0/VSTSDB/Deploy:/cygdrive/c/Program Files (x86)/Mic
rosoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft
Visual Studio 10.0/VC/BIN:/cygdrive/c/Program Files (x86)/Microsoft Visual Studi
o 10.0/Common7/Tools:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cyg
drive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Mic
rosoft Visual Studio 10.0/VC/VCPackages:/cygdrive/c/Program Files (x86)/HTML Hel
p Workshop:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Team Too
ls/Performance Tools:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0
A/bin/NETFX 4.0 Tools:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.
0A/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cyg
drive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/
cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x8
6)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL S
erver/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn
:/cygdrive/c/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0:/cygdr
ive/c/Program Files/TortoiseHg:/cygdrive/c/Program Files (x86)/GtkSharp/2.12/bin
:/cygdrive/c/Users/tim/AppData/Roaming/npm:/cygdrive/c/Program Files (x86)/nodej
s:/cygdrive/c/Program Files (x86)/Common Files/Intuit/QBPOSSDKRuntime:/cygdrive/
c/Program Files (x86)/Git/cmd:/usr/local/bin:/usr/bin/

tim@xxx ~
$ which link
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/BIN/link

For a default installation of Cygwin, PATH is set is /etc/profile. You can modify PATH so that /usr/local/bin:/usr/bin are appended rather than prepended.

# PATH="/usr/local/bin:/usr/bin:${PATH}"
PATH="${PATH}:/usr/local/bin:/usr/bin/"

Resulting in:

Setting environment for using Microsoft Visual Studio 2010 x86 tools.

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>c:\cygwin\cygwin.bat

tim@xxx ~
$ printenv PATH
/cygdrive/c/Program Files (x86)/Microsoft F#/v4.0:/cygdrive/c/Program Files (x86
)/Microsoft Visual Studio 10.0/VSTSDB/Deploy:/cygdrive/c/Program Files (x86)/Mic
rosoft Visual Studio 10.0/Common7/IDE:/cygdrive/c/Program Files (x86)/Microsoft
Visual Studio 10.0/VC/BIN:/cygdrive/c/Program Files (x86)/Microsoft Visual Studi
o 10.0/Common7/Tools:/cygdrive/c/Windows/Microsoft.NET/Framework/v4.0.30319:/cyg
drive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Program Files (x86)/Mic
rosoft Visual Studio 10.0/VC/VCPackages:/cygdrive/c/Program Files (x86)/HTML Hel
p Workshop:/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/Team Too
ls/Performance Tools:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.0
A/bin/NETFX 4.0 Tools:/cygdrive/c/Program Files (x86)/Microsoft SDKs/Windows/v7.
0A/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cyg
drive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/
cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x8
6)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL S
erver/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn
:/cygdrive/c/Program Files (x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0:/cygdr
ive/c/Program Files/TortoiseHg:/cygdrive/c/Program Files (x86)/GtkSharp/2.12/bin
:/cygdrive/c/Users/tim/AppData/Roaming/npm:/cygdrive/c/Program Files (x86)/nodej
s:/cygdrive/c/Program Files (x86)/Common Files/Intuit/QBPOSSDKRuntime:/cygdrive/
c/Program Files (x86)/Git/cmd:/usr/local/bin:/usr/bin/

tim@xxx ~
$ which link
/cygdrive/c/Program Files (x86)/Microsoft Visual Studio 10.0/VC/BIN/link
萌逼全场 2025-01-10 06:08:08

我认为更干净的方法是使用在 Cygwin 的 /etc/profile 中创建的 ORIGINAL_PATH 变量。不要修改此文件,而是修改 .bashrc 文件以使用 ORIGINAL_PATH,然后附加 /usr/local/bin/usr /bin

.bashrc

export PATH=$ORIGINAL_PATH:/usr/local/bin:/usr/bin

那么你就不必修改Cygwin安装文件了。

I think that a cleaner method is to use the ORIGINAL_PATH variable that is created in Cygwin’s /etc/profile. Instead of modifying this file, modify your .bashrc file to use ORIGINAL_PATH and then append /usr/local/bin and /usr/bin.

.bashrc:

export PATH=$ORIGINAL_PATH:/usr/local/bin:/usr/bin

Then you don't have to modify the Cygwin installation files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文