This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Newbie needs help using mingw with cygwin


Mark wrote:

I had thought that by modifying my etc/profile to pick up mingw istead of the
GCC bundled in cygwin

If that's the limit of your goal, then yes, it can be done, but it's a bit more involved than just changing the PATH. Here's the Bourne shell script I use, which I call 'mingw':


#!/bin/sh
PATH=/c/mingw/bin:/c/windows:/c/windows/system32:/c/cygwin/bin
echo "Say 'exit' to leave MinGW shell and restore Cygwin environment."
/usr/bin/bash --rcfile ~/.mingwrc

Then in ~/.mingwrc:

alias make=mingw32-make
PS1='MinGW: \W \$ '

There's a way around having to split the functionality into two files like this, but it changes the way you have to run the shell script, and that runs counter to my keyboard habits. Besides, you would then lose out on a neat side benefit: when you exit the MinGW subshell, all of the changes made to enter MinGW mode revert. This is very helpful to me when I'm testing under both environments: I work in Cygwin mode as long as I can, then pop into MinGW where and only as long as necessary. Back in Cygwin mode, my environment works just like before.

Note that the script completely rewrites the PATH to ensure that MinGW's bin directory appears before Cygwin's, so that anything they have in common always comes from the MinGW side. If you have other directories that you want in your PATH, you can tack them on in the .mingwrc file:

export PATH=$PATH:/my/path/here

By the way, I should note that I've used "mount -c /" on this system, so either do that on your system, too, or change all "/c" to "/cygdrive/c".

I alias 'make' to 'mingw32-make' to hide the Cygwin make. MinGW make has some Windows/DOS quirks in it that I happen to need. (This is why they give it a different name, by the way.) I habitually type 'make' so I can't afford to have Cygwin's make in the way while I'm working in MinGW mode. If Cygwin's make works for you, I'd recommend removing this alias, as the MinGW quirks can cause problems if you don't need them.

The change in the prompt is to remind myself that I'm in a subshell, and that exiting will take me back to Cygwin mode, not close the window. The "echo" message says much the same thing, but that only helps while it's still in your short-term memory. It's easy to forget that you're still in MinGW mode, without the custom prompt.

Now, this doesn't somehow give you the ability to build POSIX programs using only MinGW. Its only purpose is to let you use the Cygwin userland tools while building with MinGW; think of it as an alternative to MSYS. This only helps you if the program will build using pure Win32 APIs. The fact that it uses a configure script is a pretty good indicator that it uses POSIX APIs, though not an infallible one. It's possible to use autoconf for a pure Win32 program, but rarely done.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]