简体   繁体   中英

Cygwin & MinGW on windows 10

I've got an existing installation of Cygwin on my Windows 10 machine. Because I'm beginning to work with socket programming within a Windows environment I want to look at using 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:

@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...
  2. However, if I simply type path into a cmd prompt it shows the 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?

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.

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

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 . Now if someone with more experience than me could point me in the direction of how to delete part of a system variable...

1.

There are two different PATHs, one system wide and one for the user. 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. If CMD executes your little batch it prepends C:\cygwin\bin to this existing list. This PATH is only valid for this instance of CMD.

2.

Well, I have no good idea... How would you select which single path to delete from the list in 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?

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. Then write two little batches to open CMD and prepend (or what I like better, append) the respective path.

BTW, doesn't MinGW set up a start menu entry doing right this already?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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