Home > Articles > Programming > C/C++

  • Print
  • + Share This
Like this article? We recommend

Installing The XMingwin Environment

Unpack your local copy of XMingwin:

 WORKING=~/some/working/directory
 cd $WORKING
 bunzip2 mingw-cross.tar.bz2
 tar xvf mingw-cross.tar

Augment your shell's PATH

PATH="$PATH:$WORKING/bin"

or, if you're using a variation of csh,

 set path = ($path $WORKING/bin)

At this point, you're equipped to ask your new compiler its release number:

 mingw32-gcc -v

It's likely to reply:

 gcc version 2.95.3 20010315 (release)

You're almost home. Now just adjust your usual compilations slightly, to:

 mingw32-gcc -c p1.cc -o p1.obj
 mingw32-gcc -c p2.cc -o p2.obj
 mingw32-gcc -o p.exe p1.obj p2.obj -lstdc++

You just created a well-behaved Windows executable.

What was the point?

Copy <code>p.exe</code> to any Windows machine, launch it from a "DOS box", and you'll see:

 The result is 23.3.

Do you understand how momentous this is? Your Linux or other Unix desktop is a factory for the useful products you make--programs, libraries, and so on. Until now, all your products have been "native:" they work on other computers running the same operating system as yours. XMingwin demonstrates that you can multiply your factory's output. Simple shell or Makefile scripting lets you produce output for multiple operating systems, in little more time than you're expending now, and with no more recurring effort than it took to make them for one. You're now a far more productive programmer.

There's more, of course. As a programmer, you know there's a lot more to do than just compile programs: you need to validate (that is, debug) them, package them, deliver them, archive them, and so on.

Linux makes it inviting to work the same "multiplier" to your advantage in all these domains, too. Rather than copy a Windows executable by hand to a Windows host, you can cross-mount file systems, and have your programs generated under Linux show up automatically on Windows. You can also use one of the Windows emulations or remote controls available for Linux, and even automate execution and dynamic testing of your application. Put enough pieces together, and you'll have a working environment that automatically submits all your source code changes to version control, generates binary results for all operating systems, exercises regression tests for each of them, and reports the results back without any intervention.

  • + Share This
  • 🔖 Save To Your Account