简体   繁体   English

windows 10 上的 Cygwin 和 MinGW

[英]Cygwin & MinGW on windows 10

I've got an existing installation of Cygwin on my Windows 10 machine.我的 Windows 10 机器上已经安装了 Cygwin。 Because I'm beginning to work with socket programming within a Windows environment I want to look at using MinGW.因为我开始在 Windows 环境中使用套接字编程,所以我想看看使用 MinGW。

I have them both on my machine, but want to look at simple ways of 'hot swapping' between them.我的机器上都有它们,但想看看它们之间“热交换”的简单方法。 There is a previous question here: GCC on Cygwin coexisting with MinGW which has the following.cmd file:这里有一个先前的问题: Cygwin 上的 GCC 与 MinGW 共存,它具有以下.cmd 文件:

@echo off
rem file: start cmd with cygwin's path
cmd.exe  /k path=C:\cygwin\bin;%path%

Now if I run this as administrator a couple of things happen which I don't at this point understand:现在,如果我以管理员身份运行它,会发生一些我目前不明白的事情:

  1. If a navigate to control panel -> system -> advanced system settings -> Advanced tab -> Environment Variables -> edit path - nothing shows...如果导航到control panel -> system -> advanced system settings -> Advanced tab -> Environment Variables -> edit path - 没有显示...
  2. However, if I simply type path into a cmd prompt it shows the C:\cygwin\bin .但是,如果我只是在 cmd 提示符中输入path ,它会显示C:\cygwin\bin

So I suppose my questions are:所以我想我的问题是:

a.一个。 whats the difference between the above?以上有什么区别?

b.湾。 If the.cmd file adds a path item, whats the easiest way of taking one out?如果.cmd文件添加了一个路径项,那么最简单的取出方法是什么?

My thinking is if I don't have anything in my path, then typing gcc --version into a cmd prompt should show an error which it doesn't at the moment due to point 2 above.我的想法是,如果我的路径中没有任何东西,那么在 cmd 提示中键入gcc --version应该会显示一个错误,由于上面的第 2 点,它目前没有。

Hopefully, I've made sense.希望我说得有道理。 Any help much appreciated as always.一如既往地感谢任何帮助。
Rob

EDIT 1: I found the following: Command line to remove an environment variable from the OS level configuration编辑 1:我发现以下内容: 从操作系统级别配置中删除环境变量的命令行

which has the following command prompt:它具有以下命令提示符:

REG delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V FOOBAR

This is used to delete a system variable FOOBAR .这用于删除系统变量FOOBAR Now if someone with more experience than me could point me in the direction of how to delete part of a system variable...现在,如果比我更有经验的人可以指出如何删除系统变量的一部分的方向......

1. 1.

There are two different PATHs, one system wide and one for the user.有两种不同的 PATH,一种是系统范围的,一种是用户的。 The latter is built from the system's one and extended by the settings' content.后者是从系统构建的,并由设置内容扩展。

The resulting PATH is just the base when a program starts.生成的 PATH 只是程序启动时的基础。 If CMD executes your little batch it prepends C:\cygwin\bin to this existing list.如果 CMD 执行您的小批量,它C:\cygwin\bin到这个现有列表中。 This PATH is only valid for this instance of CMD.此 PATH 仅对 CMD 的此实例有效。

2. 2.

Well, I have no good idea... How would you select which single path to delete from the list in PATH?好吧,我没有好主意...您将如何 select 从 PATH 列表中删除哪个单一路径? By index, by contents, by what?按索引,按内容,按什么?

There might be some way to do it with existing commands like "for", but why is the path in PATH at all?可能有一些方法可以使用现有的命令,如“for”,但为什么路径在 PATH 中呢?

It you like to have two different environments to use either Cygwin or MinGW tools, I'd recommend to set the system's and/or user's base PATH (by the settings dialogue) without both of them.如果您希望有两种不同的环境来使用 Cygwin 或 MinGW 工具,我建议您设置系统和/或用户的基本 PATH(通过设置对话框)而不使用这两种工具。 Then write two little batches to open CMD and prepend (or what I like better, append) the respective path.然后写两小批打开 CMD 并预先(或者我更喜欢,附加)各自的路径。

BTW, doesn't MinGW set up a start menu entry doing right this already?顺便说一句,MinGW 不是已经设置了一个开始菜单条目吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM