The Full Wiki

Cygwin: Wikis

Advertisements
  

Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

Encyclopedia

From Wikipedia, the free encyclopedia

Cygwin
Cygwin X11 rootless WinXP.png
Running Cygwin under Windows XP
Developer(s) Cygnus Solutions, Red Hat and others
Initial release 1995
Stable release 1.7.1-1 / 23 December 2009
Written in C/C++
Operating system Microsoft Windows
Type Compatibility layer
License GNU GPLv2
Website http://www.cygwin.com/

Cygwin (pronounced /ˈsɪɡwɪn/,[1] SIG-win) is a Unix-like environment and command-line interface for Microsoft Windows. Cygwin provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment. Thus it is possible to launch Windows applications from the Cygwin environment, as well as to use Cygwin tools and applications within the Windows operating context.

Cygwin consists of two parts: a Dynamic-link library (DLL) as an API compatibility layer providing a substantial part of the POSIX API functionality, and an extensive collection of software tools and applications that provide a Unix-like look and feel.

Cygwin was originally developed by Cygnus Solutions, which was later acquired by Red Hat. It is free and open source software, released under the GNU General Public License version 2. Today it is maintained by employees of Red Hat, NetApp and many other volunteers. Corinna Vinschen and Christopher Faylor are currently the managers of the Cygwin development team.

Contents

Description

Cygwin consists of a library that implements the POSIX system call API in terms of Win32 system calls, a GNU development toolchain (such as GCC and GDB) to allow software development, and a large number of application programs equivalent to those on the Unix system. Many Unix programs have been ported to Cygwin, including the X Window System, KDE, GNOME[2], Apache, and TeX. Cygwin permits installing inetd, syslogd, sshd, Apache, and other daemons as standard Windows services, allowing Microsoft Windows systems to emulate Unix and Linux servers.

Cygwin programs are installed by running Cygwin's "setup" program, which downloads the necessary program and feature package files from repositories on the Internet. Setup can install, update, and remove programs and their source code packages. A full installation may take up to 4 GB of hard disk space.

Efforts to reconcile concepts that differ between Unix and Windows systems include:

  • A Cygwin-specific version of the Unix mount command allows Windows paths to be mounted as "filesystems" in the Unix file space. Mount information is normally stored in the registry. Filesystems can be mounted as binary ones (by default), or as text-based ones, which enables automatic conversion between LF and CRLF endings. (This only affects programs that call open() or fopen() without specifying text or binary. Programs installed by Cygwin's setup program always open files in binary mode when appropriate, thus avoiding the problem.) Disk drives (C:, D:, etc.) are also denominated /cygdrive/c, /cygdrive/d, etc. Windows network paths of the form \\HOST\SHARE\FILE are mapped to //HOST/SHARE/FILE.
  • Full-featured /dev and /proc file systems are provided. /proc/registry provides direct filesystem access to the registry.
  • Symbolic links are provided, and use .LNK files (Windows shortcuts) containing Cygwin-specific information, and with the "system" attribute set to speed up processing. However, native NTFS symbolic links are handled differently; using the rm deletes the linked file instead of the link itself. Old Cygwin versions handled symbolic links using plain text files with hidden attribute set and a single line of text, pointing to the destination file or directory.
  • The Solaris API for handling access control lists (ACLs) is supported and maps to the Windows NT ACL system.
  • Special formats of /etc/passwd and /etc/group are provided that include pointers to the Windows equivalent SID's (in the GECOS field), allowing for mapping between Unix and Windows users and groups.
  • Various utilities are provided for converting between Windows and Unix file formats, for handling line ending (CRLF/LF) issues, for displaying the DLLs that an executable is linked with, etc.
  • The Cygwin library also interfaces to existing Windows libraries. It is possible to call Windows functions like waveOut from Cygwin executable itself.

The version of gcc that comes with Cygwin has various extensions for creating Windows DLLs, specifying whether a program is a windowing or console mode program, adding resources, etc. It also provides support for compiling MinGW-compatible executables (that is, executables that do not require Cygwin to be installed to run, or more specifically, executables that don't require Cygwin's CYGWIN1.DLL, which provides the POSIX compatibility layer).

Cygwin is used heavily for porting many popular pieces of software to the Windows platform. It is used to compile Sun Java, OpenOffice.org, and even server software, like lighttpd.

Red Hat normally licenses the Cygwin library under the GNU General Public License version 2 with an exception to allow linking to any free and open source software whose license conforms to the Open Source Definition. Red Hat also sells commercial licenses to those who wish to redistribute programs that use the Cygwin library under proprietary terms.

History

Cygwin began in 1995 as a project of Steve Chamberlain, a Cygnus engineer who observed that Windows NT and 95 used COFF as their object file format, and that GNU already included support for x86 and COFF, and the C library newlib. He thought it would be possible to retarget GCC and produce a cross compiler generating executables that could run on Windows. This proved indeed practical and a prototype was quickly developed.

The next step was to attempt to bootstrap the compiler on a Windows system, requiring sufficient emulation of Unix to let the GNU configure shell script run. A Bourne shell-compatible command interpreter, such as bash, was needed and in turn a fork system call emulation and standard input/output. Windows includes similar functionality, so the Cygwin library just needed to provide a POSIX-compatible application programming interface (API) and properly translate calls and manage private versions of data, such as file descriptors.

Initially, Cygwin was called gnuwin32 (not to be confused with the current GnuWin32 project). The name was changed to Cygwin32 to emphasize Cygnus' role in creating it. When Microsoft registered the trademark Win32, the 32 was dropped to simply become Cygwin.

By 1996, other engineers had joined in, because it was clear that Cygwin would be a useful way to provide Cygnus' embedded tools hosted on Windows systems (the previous strategy had been to use DJGPP). It was especially attractive because it was possible to do a three-way cross-compile, for instance to use a hefty Sun workstation to build, say, a Windows-x-MIPS cross-compiler, which was faster than using the PC of the time. Starting around 1998, Cygnus also began offering the Cygwin package as a product of interest in its own right.

Features

  • Supports native application building using MinGW
  • Supports remote logins using rsh, ssh, and telnet
  • Embedded cross platforms support, used for many platforms including PSP and PS2
  • X and OpenGL support
  • Windows Vista support

Drawbacks

  • Speed to initiate cygwin and to launch programs
  • Multiple bugs in key code recognition
  • Requires a compatibility layer DLL

Derivatives

Cygnix is a limited X11 environment based on Cygwin. Its name is an abbreviation of "CYGnus pseudo-uNIX".

There are implementations of Cygnix in Windows 95 / 98 / ME and Windows NT / 2000 / XP.

There was also a package called Cygnix for AmigaOS 4. It is now renamed to AmiCygnix. This package is not based on Cygnix for Windows. It is based on an X server port for AmigaOS 3.x for 68k Amigas.

Extensions

Extensions to Cygwin are available, such as Cygwin/X, a port of the X Window System, and in turn, the KDE Desktop as KDE on Cygwin. However KDE on Cygwin has been phased out as KDE 4 has been ported to run natively on Windows.[3]

Other integration tools

Several open-source and proprietary alternatives are available for simultaneous access to both Windows and UNIX environments on the same hardware.

Toolsets like Microsoft Windows Services for UNIX (SFU), UWIN, MKS Toolkit for Enterprise Developers and Hamilton C shell also aim to provide a Unix-like user and development environment. They implement at least a shell and a set of the most popular utilities. Most include the familiar GNU and/or Unix development tools, including make, yacc, lex and a cc command which acts a wrapper around a supported C compiler. SFU also includes the GCC compiler.

MinGW is a native software port of the GNU Compiler Collection (GCC) to Microsoft Windows, along with a set of freely distributable import libraries and header files for the Windows API. MinGW allows developers to create native Microsoft Windows applications. In addition, a component of MinGW known as MSYS (Minimal SYStem) provides a lightweight Unix-like shell environment including rxvt, bash and a selection of POSIX tools sufficient to enable autoconf scripts to run.[4][5]

In addition, there are numerous virtualization solutions that provide x86 platform virtualization to run Windows and Unix-like operating systems simultaneously on the same hardware, but without the integration of the environments that Cygwin provides. Some, like VirtualBox and VMware Player run on Windows and Linux hosts and can run many other operating systems. Cooperative Linux (in short coLinux) runs a full, but modified Linux kernel like a driver under Windows, effectively making Windows and Linux two coroutines, using cooperative multitasking to switch between them.

Wine is a mirror image of Cygwin - it is a free and open source compatibility layer for Unix-like operating systems on the x86 or x86-64 architecture that can execute programs written for Microsoft Windows.

See also

References

External links

Advertisements

Wikibooks

Up to date as of January 23, 2010

From Wikibooks, the open-content textbooks collection

Contents

Before experiencing X

Cygwin/X is installed by selecting the necessary packages from the X11 category with the standard Cygwin installer. Users unsure of what is needed should install all of the X11 components.

Accessing X of your Local Cygwin

You can run the X server and the Window Manager locally and get the X Window GUI environment.

There are various ways you can do this. They are as follows:

MultiWindow Mode

In the multiwindow mode, there is an internal window manager that creates a Windows window to display the X application on the Windows desktop.

X

X is a soft-link (shortcut from Windows standpoint) to /usr/X11R6/bin/XWin.

  1. Start Cygwin
  2. Execute the command, X -multiwindow &. (Cygwin/X window comes up)
  3. Execute the command, export DISPLAY=127.0.0.1:0.0
  4. Execute the command, xclock &. (xclock comes up).

Now you can run any X application. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

startxwin.bat

  1. Run startxwin.bat from usr\X11R6\bin\ folder where your Cygwin is installed. This can be done by double clicking on the batch file. It will bring up an xterm window. If you don't want to go through the hassle of finding this file, you can simply run the startxwin-multiwindow.bat file which should be present on your desktop. Both the scripts are very similar.
  2. Execute the command, xclock & in the xterm window. (xclock comes up).

Now you can run any X application. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

startxwin.sh

  1. Start Cygwin (The Bash shell comes up)
  2. Execute the command, startxwin.sh &. It'll bring up an xterm window.
  3. Execute the command, xclock & in the xterm window. (xclock comes up).

Now you can run any X application. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

startx

  1. Start Cygwin (The Bash shell comes up)
  2. Execute the command, startx &. It'll bring up an xterm window.
  3. Execute the command, xclock & in the xterm window. (xclock comes up).

Now you can run any X application. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

External Local Window Manager

If you want the complete desktop environment, you will have to run a window manager or Linux desktop to send the GUI to your X server. This section is a discussion on this topic.

X

X is a soft-link (shortcut from Windows standpoint) to /usr/X11R6/bin/XWin.

  1. Start Cygwin (The Bash shell comes up)
  2. Execute the command, X &. (Cygwin/X window comes up)
  3. Execute the command, export DISPLAY=127.0.0.1:0.0
  4. Execute the command, wmaker &
  5. Check your Cygwin/X window. You have got the desktop. :-)

Accessing X of a Remote Box

In the following discussion the following IP addresses and user name have been assumed:-

  • remote_box - IP Address or domain name of remote box
  • my_system - IP Address or domain name of your Windows system
  • user_name - A valid account in the remote box

X11 Forwarding

For some of the methods described in this section, X Forwarding should be enabled in the remote box. Whether this is enabled or not can be found out from the file, /etc/ssh/sshd_config of the remote box.

If there is a line X11Forwarding yes, it means X11 Forwarding is enabled and you can go ahead with the steps below.

If it is, X11Forwarding no, X11 Forwarding is disabled. You can edit it to enable it. Of course this can be done by the "root" only. If you need X11 Forwarding enabled and you are not the "root" of the box, you'll have to talk to its admin.

MultiWindow Mode

In the multiwindow mode, there is an internal window manager that creates a Windows window to display the X application on your Windows desktop.

X

X is a soft-link (shortcut from Windows standpoint) to /usr/X11R6/bin/XWin directory.

  1. Start Cygwin (The Bash shell comes up)
  2. Execute the command, X -multiwindow &. (Cygwin/X window comes up)
  3. Execute the command, export DISPLAY=127.0.0.1:0.0
  4. Log in to the remote box with the command, ssh -X user_name@remote_box
  5. Execute the command, xclock &. (xclock comes up).

Now you can run any X application on the remote box. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

For the above method to work, X11 Forwarding should be enabled in the remote box.

startxwin.bat

  1. Run startxwin.bat from usr\X11R6\bin\ folder where your Cygwin is installed. This can be done by double clicking on the batch file. It'll bring up an xterm window. If you don't want to go through the hassle of finding this file, you can simply run the startxwin-multiwindow.bat file which should be present on your desktop. Both the scripts are exactly similar.
  2. Execute the command, xhost remote_box to provide remote box access to the X server running on your Cygwin. Alternatively you can execute the command, xhost + to disable access control completely, so that any client can connect to your X server.
  3. Log in to the remote box with the command, ssh -X user_name@remote_box
  4. Execute the command, export DISPLAY=my_system:0.0 on the remote box.
  5. Execute the command, xclock & in the xterm window. (xclock comes up).

Now you can run any X application on the remote box. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

If X11 Forwarding is enabled in the remote box, you can omit step 2 and step 4.

startxwin.sh

  1. Start Cygwin (The Bash shell comes up)
  2. Execute the command, startxwin.sh &. It'll bring up an xterm window.
  3. Execute the command, xhost remote_box to provide remote box access to the X server running on your Cygwin. Alternatively you can execute the command, xhost + to disable access control completely, so that any client can connect to your X server.
  4. Log in to the remote box with the command, ssh -X user_name@remote_box
  5. Execute the command, export DISPLAY=my_system:0.0 on the remote box.
  6. Execute the command, xclock & in the xterm window. (xclock comes up).

Now you can run any X application on the remote box. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

If X11 Forwarding is enabled in the remote box, you can omit step 3 and step 4.

startx

  1. Start Cygwin (The Bash shell comes up)
  2. Execute the command, startx &. It'll bring up an xterm window.
  3. Execute the command, xhost remote_box to provide remote box access to the X server running on your Cygwin. Alternatively you can execute the command, xhost + to disable access control completely, so that any client can connect to your X server.
  4. Log in to the remote box with the command, ssh -X user_name@remote_box
  5. Execute the command, export DISPLAY=my_system:0.0 on the remote box.
  6. Execute the command, xclock & in the xterm window. (xclock comes up).

Now you can run any X application on the remote box. They open up in separate windows individually with your windows title-bar, caption buttons and border. You don't get the desktop environment in this case.

If X11 Forwarding is enabled in the remote box, you can omit step 3 and step 4.

PuTTY

  1. Open PuTTY
  2. From the Category tree, select "Session" and enter the host details.
  3. From the Category tree, select "Connection > SSH > X11" and check the "Enable X11 Forwarding" checkbox.
  4. Click "Open" and login.
  5. Run an X Server on your Windows machine. There are various ways to do it.
    1. Open Cygwin and run X -multiwindow &.
    2. Run startxwin.bat from Windows or open Cygwin and run startx, startxwin.sh. An extra xterm opens which might be a pain since you don't need it. (The previous two steps save you from that).
  6. Get back to your PuTTY window and execute the command, xclock & (xclock comes up).
  7. Check your Cygwin/X window. (You have got the desktop :-))

For this method to work X11 Forwarding should be enabled in the remote box and you should be logging into the remote box using the SSH protocol.

If you want to save yourself from the first four steps, simply add the path of the PuTTY directory to the Windows PATH variable or you can simply put PuTTY.exe in the Windows directory. Henceforth, you can simply execute the command, putty -X user_name@remote_host from anywhere and then proceed with step 5.

External Remote Window Manager

If you want the complete desktop environment of a remote box, you will have to run a window manager or Linux desktop on the remote box and forward the X output to the X server of your Windows PC so that you can see the GUI on your X server. This section is a discussion on how this can be done.

X

X is a soft-link (shortcut from Windows standpoint) to /usr/X11R6/bin/XWin directory.

  1. Start Cygwin (The Bash shell comes up)
  2. Execute the command, X &. (Cygwin/X window comes up)
  3. Execute the command, export DISPLAY=127.0.0.1:0.0
  4. Log in to the remote box with the command, ssh -X user_name@remote_box
  5. Execute the command, wmaker & on the box.
  6. Check your Cygwin/X window. You have got the desktop of the remote box. :-)

For the above method to work, X11 Forwarding should be enabled in the remote box.

PuTTY

  1. Open PuTTY
  2. From the Category tree, select "Session" and enter the host details.
  3. From the Category tree, select "Connection > SSH > X11" and check the "Enable X11 Forwarding" checkbox
  4. Click "Open" and login.
  5. Execute the command, X &, to run the Cygwin X server on your Windows system.
  6. Get back to your PuTTY window and run wmaker &.
  7. Check your Cygwin/X window. (You have got the desktop :-))

For this method to work X11 Forwarding should be enabled in the remote box and you should be logging into the remote box using the SSH protocol.

If you want to save yourself from the first four steps, simply add the path of the PuTTY folder to the Windows PATH variable for once and ever. Henceforth, you can simply execute the command, putty -X user_name@remote_host from anywhere and then proceed with step 5.

Recipe: Run an X application (on a remote UNIX machine) with a local Windows X Server

- Install Cygwin including the X11 client and Secure Shell SSH.

- Start Cygwin Bash Shell by clicking on the Cygwin icon.

- Start the X Server (This opens another Bash Shell in an X window.

 $ /usr/X11R6/bin/startx

- Allow the remote computer to X Client into your local computer by adding the remoter server to the access control list.

 $ xhost +RemoteServerName or IP Address

- Use ssh to access the remoter computer. You will be prompted for a UserID and Password.

 $ ssh -X +RemoteServerName or IP Address

- While on the remote computer execute the program you want in background mode.

 $ +ProgramYouWant &

Cygwin Tips

  • Install Cygwin to the default directory, C:\cygwin\ for consistency.
  • When installing, check cygrunsrv to allow for running sshd as a Windows service
  • To use rxvt as the preferred console, create a Windows shortcut with the Target set to C:\cygwin\bin\rxvt.exe --loginShell -sr and Start in set to C:\cygwin\bin.
  • To enlarge the console window and add a title, add -geometry "80x50" -title Cygwin to the Target.
  • To start an SSH session, add -e ssh user@machine.name.com to the Target.
  • To change the default home directory to My Documents on NT-based Windows (NT/2000/XP/2003/Vista), create an environment variable called HOME with value of C:\DOCUME~1\USERNAME\MYDOCU~1 (where USERNAME is your Windows login username).
  • Create an environment variable called SHELL with value of /bin/bash.
  • Make sure c:\cygwin\bin; is added to the Path environment variable.
  • To mount prefix from /cygdrive to / type this command once, mount -s --change-cygdrive-prefix /
  • Or keep cygdrive as is and create mounts (e.g. mount -u C: /C) for every drive.
  • Emacs and vi are the most popular editors but Nano is the easiest to use.
  • Create a file called .bash_profile in the HOME directory containing the following lines:
    • alias dir='ls -lav --color=auto'
    • EDITOR=nano; export EDITOR
    • VISUAL=nano; export VISUAL
  • To use the clear command install the ncurses package (in the lib category)

Advertisements






Got something to say? Make a comment.
Your name
Your email address
Message