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

时间:2012-02-06 23:24:41

标签: cygwin

我正在尝试使用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 / 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文件(x86)/ HTML帮助研讨会:/ cygdrive / c / Program Files(x86)/ Microsoft Vis ual Studio   10.0 /团队工具/性能工具:/ cygdrive / c / Program Files(x86)/ Mic rosoft SDKs / Windows / v7.0A / bin / NETFX 4.0工具:/ cygdrive / c / Program   文件(x86)/ Mi crosoft SDKs / Windows / v7.0A / bin:/ cygdrive / c / Program   文件/公共文件/ Microsoft共享/ Windows   住:/ cygdrive / C /窗/ 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网页/ v1.0:/ cygdrive / c / Program   Files / TortoiseHg:/ cygdrive / c / Program Files   (86)/GtkSharp/2.12/bin:/cygdrive/c/Users/tim/AppData/Roaming/npm:/cygdrive/c/P   rogram Files(x86)/ nodejs:/ cygdrive / c / Program Files(x86)/ Common   文件/ Intuit / QB POSSDKRuntime:/ cygdrive / c / Program Files(x86)/ Git / cmd

ICU告诉我

  

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

更新。我的cygwin.bat看起来像这样:

  

@echo off

     

C:chdir C:\ cygwin \ bin

     

bash --login -i

不是很有帮助。

2 个答案:

答案 0 :(得分:7)

对于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

答案 1 :(得分:4)

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

.bashrc

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

然后您不必修改Cygwin安装文件。