2.5.1 Cygwin
Cygwin is described as a “Linux-like environment” for Windows. It was originally developed in 1995 by Cygnus Solutions, which was subsequently purchased by Red Hat. Red Hat now maintains both the open source version and a licensable, proprietary version for people who want to maintain their own applications as proprietary.
Cygwin consists of two basic parts:
• A Windows DLL (cygwin1.dll) that acts as a Linux API emulation layerproviding substantial Linux API functionality.
• A collection of tools that provide Linux look-and-feel. Among these tools is the GNU tool chain.
The primary motivation for Cygwin is to provide Unix/Linux functionality in a Windows environment, but it is not a way to run native Linux apps under Windows. Applications must be rebuilt from source to run in the Cygwin environment.
Nevertheless, it can be a useful tool for experimenting with C development with Eclipse under Windows. Note, however, that to build code for an embedded target, you will need a build of the GNU tool chain that supports your target processor. Many chip and board vendors provide Linux-based tool chains for their architectures, but rarely offer the tool chain built for Cygwin. So you will likely be on your own to build the target tool chain.
Another perceived drawback to Cygwin, for desktop applications anyway, is that the cygwin1.dll
is released under the GPL. This means that anything that links with it, i.e., an application, is considered a “derivative work” and must itself be released under the GPL. On the other hand, this wouldn’t be a problem for an embedded application intended for a target that runs real Linux. It is widely accepted that a Linux application running in user space and using only the published kernel APIs is not a derivative work.
Another nice feature of Cygwin is that it happens to include NFS and TFTP servers.
Go to http://www.cygwin.com/ and click on the Install Cygwin now icon. There are several icons and links on this page that point to the same target, setup.exe
.
When you click one of these links, Windows asks if you want to run or save the file. I generally save executables and then run them locally, but it’s your call.
In either case, execute setup.exe
. You may get a warning saying that the publisher could not be verified and asking if you really want to run it. Go ahead, it’s safe. Following an initial information screen, you are offered three installation types:
• Install from Internet (default)
• Download Without Installing
• Install from Local Directory
The next screen lets you specify a root directory and select a couple of options. The recommended defaults for the options are good. Next you’re asked to select a directory in which the downloaded packages will be stored. These are then available for subsequent reinstallation. Oddly, the default is the Desktop for the current user. I prefer to put stuff like this in the \downloads
directory.
The next screen asks how you connect to the Internet. Select appropriately and continue. You are presented with a list of download mirror sites with the intention that you pick one geographically close to you. But again, most of the names offer no clue about where they may be located. Continuing to the next screen causes another setup program to be downloaded and you are presented with a package selection menu.
Sadly, this is not the most intuitive or user-friendly menu. Expand the Devel category by clicking on the +. The result is shown in Figure 2.4. Most of the packages are designated as “Skip,” meaning they won’t be installed. Scroll down to the gcc-core package and click on the word “Skip” in the New column. Skip changes to a version number and the Bin? column changes to a check box. This package, in its binary form, is now selected for installation. The Src? column is an open box giving you the option of downloading the source code as well. You might want to select this if you need to build a target version of gcc.
Scroll down and select gdb: The GNU Debugger as well. Again, you might want to check the Src? box if you will need to build a version for your target architecture. That should be all we need for C development. Now expand the net category and select the nfs-server and xinetd. Clicking Next starts the download. This is a lengthy process because we are, after all, building a fairly complete Linux environment. It’s much more than the few packages we selected here.
Figure 2.4: Cygwin package selection.
Following the download, you have the option of creating icons on the desktop or in the Start Menu. You’re done. You’ll find a folder named cygwin\
in the folder specified for installation. It turns out to be the root directory of the Cygwin Linux environment. You’ll also find a rather oddly named folder in the download directory that has a setup.ini
file reflecting your package selection and a folder containing all of the download compressed package files.
Double-click the Cygwin icon and you’ll get a bash shell as shown in Figure 2.5. Play around with some of the basic commands just to prove it really is a bash shell. Later we’ll look at how to configure Eclipse to find the gcc compiler and other tools.
Figure 2.5: Cygwin bash shell.
2.5.2 MinGW
MinGW, which stands for “Minimalist GNU for Windows,” is the other popular approach to installing the GNU tool chain on Windows. The primary difference between it and Cygwin is that MinGW uses the Windows C runtime libraries (mscvrt) instead of GNU’s libc. This means that a compatibility layer is not needed, thus getting around the GPL issues associated with Cygwin.
Of course, this also means that MinGW generates native Windows code, which is fine for learning about and experimenting with CDT, but won’t get you very far in building embedded target code. Nevertheless, the Eclipse documentation suggests that MinGW’s direct support for the Windows environment provides the best integration with CDT.
MinGW is strictly an open source project and is hosted at http://sourceforge.net/index.php.
The MinGW download page is http://www.sourceforge.net/project/showfiles.php?group_id=2435. The first item in the list is MinGW-5.1.3. Clicking the Download button brings up another page with the actual file, MinGW-5.1.3.exe
. Much like Cygwin, this is an installer that guides you through the installation. Start the program, select Download, and install. After agreeing to the license you can choose which package to instalclass="underline" Previous, Current, or Candidate. I recommend Current.
Select the MinGW base tools and the g++ compiler components (Figure 2.6). Select other compilers if you wish. Don’t select MinGW Make. There’s a more complete implementation of make called MSYS that you’ll install in a subsequent step. Select an install location and a Start Menu folder, and click Install. There’s about 60 MB to download, so it takes a while.
Figure 2.6: MinGW component selection.
Oddly, the MinGW installer doesn’t install gdb. It can be downloaded at http://www.downloads.sourceforge.net/mingw/gdb-6.6.tar.bz2. Extract the contents of this file to the same location as MinGW.
If you want to create your own makefiles for use with CDT, you should install MSYS, also part of the MinGW project. MSYS, which stands for Minimal SYStem, is a POSIX-like command line interpreter (CLI) that serves as an alternative to theWindows command prompt, cmd.exe
. As such, it facilitates the execution of POSIX-style build scripts and makefiles that are normally part of Open Source projects. The CLI is essentially a Bourne shell.