Cygwin User Guide

Source: Internet
Author: User
Tags types of tables

Cygwin is a UNIX simulation environment running on the Windows platform, which is Cygnus
The free software developed by solutions (the company has developed many good things, famous for its ECOs, but has now been acquired by RedHat ). It is used to learn Unix/Linux operations
Environment, or applications from UNIX to WindowsProgramPorting or some special development work, especially using the GNU tool set for embedded system development on Windows.
It is often used. As embedded system development becomes increasingly popular in China, more and more developers are interested in cygwin. This article will introduce it.

According to the cygwin user guide, I hope to help you. Indicate errors.

1 Introduction
Cygwin
Is a UNIX simulation environment running on Windows platform, is Cygnus
The free software developed by solutions (the company has developed many good things, famous for its ECOs, but has now been acquired by RedHat ). It is used to learn Unix/Linux operations
Environment, UNIX to Windows applications, or some special development work, especially the use of GNU tool set for embedded system development on Windows.
It is often used. As embedded system development becomes increasingly popular in China, more and more developers are interested in cygwin. This article will introduce it.

2 mechanism
Cygnus
at the beginning, GCC, GDB, and gas development tools were improved so that they could generate and explain Win32 target files. Then, they will port these tools to the Windows platform
. One solution is to greatly modify the Source Code of these tools based on Win32
APIs. This obviously requires a lot of work. Therefore, they adopt a different method-they write a shared library (cygwin
DLL ), encapsulate Unix-style calls (such as fork, spawn, signals, select, and sockets) that are not available in Win32
APIs, that is, they wrote a simulation layer for the UNIX System Library Based on the
Win32
API. In this way, you only need to connect the source Code of these tools to the shared library, you can use a cross compiler on a unix host to generate a tool set that can run on
Windows. Based on these development tools transplanted to the Windows platform, Cygnus gradually uses other tools (almost no need to modify the source code,
just need to modify their configuration script) the software is transplanted to Windows. In this way, running bash, development tools, and user tools on Windows seems to work on UNIX.
for a more detailed description of cygwin implementation, please refer to the http://cygwin.com/cygwin-u...

(cygwin.com seems to be blocked in China Telecom ADSL. I don't know why .)
3 install cygwin
3.1 install
to install cygwin of network version, you can go to the http://cygwin.com, click "Install cygwin now! ". This example will first download a GUI installer called setup.exe, which can be used to download a complete cygwin. The installation can be easily performed according to the instructions on each screen.
3.2 Environment Variables
before running Bash, you should set some environment variables. Cygwin provides a. BAT file with the most important environment variables configured. It is the safest way to start bash. The. BAT file is installed in the root directory of cygwin. You can edit the file as needed.
the cygwin variable is used to perform multiple global settings for the cygwin runtime system. At the beginning, you can choose not to set cygwin or set it to TTY in the DOS box in a format similar to the following before executing bash.
C: \> set cygwin = tty notitle glob

Path
The variable is used by the cygwin application as the path list for searching intellectual files. When a cygwin process is started, the variable is in Windows format (e.g.
C: \ winnt \ system32; C: \ WINNT) to Unix format (e.g .,
/Winnt/system32:/WINNT ). If you want to use the cygwin tool set without running bash, path should contain at least X: \ cygwin
\ Bin, where X: \ cygwin is the cygwin directory in your system.
The Home variable is used to specify the main directory. We recommend that you define this variable before executing bash. When
When the cygwin process is started, the variable is also converted from the Windows format to the Unix format. For example, the home value on the author's machine is c: \ (doscommand set
The value set home = xxx can be seen.) In bash, the value of ECHO $ home is/cygdrive/C.
The term variable specifies the terminal type. If beauty sets it, it is automatically set to cygwin.
LD_LIBRARY_PATH is used by the cygwin function dlopen () as the path list for searching. DLL files. This variable is also converted from windows to Unix. Most cygwin applications do not use dlopen, so this variable is not required.
3.3 change cygwin's maximum storage capacity
Cygwin
By default, the program can allocate a maximum of 384 memories.
MB (Program + data ). In most cases, you do not need to modify this restriction. However, you should modify the Registry's
HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER section. Tian Jia has a DWORD key heap_chunk_in_mb and sets its value
Memory limit, in decimal MB. You can also use regtool in cygwin to complete this setting. Example:
Regtool-I set/HKLM/software/Cygnus \ solutions/cygwin/heap_chunk_in_mb 1024
Regtool-V list/HKLM/software/Cygnus \ solutions/cygwin

4. Use cygwin
This section describes the differences between cygwin and traditional UNIX systems.
4.1 map the path name
4.1.1 Introduction
Cygwin
It also supports Win32 and POSIX paths. The path separator can be either a forward slash or a backslash. UNC path names are also supported. (In the network, UNC is a method for determining the file location,
By using this method, you can ignore the physical location of the storage device, making it easier for you to use it. In Windows, Novell
Netware and other operating systems have used this specification to replace the local naming system. In UNC, we do not need to care about the Disks (or volumes) on which the files are stored, or the Disks (or volumes) on which the files are stored.
Where is the server. You can access files in the following format:
\ Server Name \ Share Name \ path \ file name
The shared name is sometimes called the logical identifier of the volume or storage device where the file is located, but it is used so that users do not have to worry about the physical location of the volume or storage device .)
POSIX-compliant operating systems (such as Linux) do not have a drive letter concept. All absolute paths start with a slash instead of a drive letter (such as C :). All file systems are subdirectories. For example, two hard disks, one of which is the root and the other may be in the/disk2 path.
Because
Assume that a single POSIX file system structure exists for programs on many UNIX systems. Therefore, cygwin maintains an internal POSIX view for Win32 file systems
The program can run correctly in windows. If necessary, cygwin will use this ing to convert between Win32 and POSIX paths.
4.1.2 cygwin Mount table
Cygwin
The Mount program in maps Win32 drive letters and network shared paths to the internal POSIX directory tree of cygwin. This is similar to the typical Unix
The Mount program is similar. For those who are unfamiliar with Unix and have a Windows background, the mount program is very similar to the early doscommand join, that is
Drive letters are used as subdirectories of other paths.
Path ing information is stored in the cygwin Mount table of the current user.
In the Windows registry. In this way, when the user logs in for the next time, the information is retrieved from the registry. Mount
There are two types of tables. In addition to each user-specific table, there are also system-specific Mount tables. Each cygwin user's installation table inherits from the system table. System tables can only be owned by users with proper permissions
(Administrator of Windows NT.
The current user's Mount table can be seen in the Registry "HKEY_CURRENT_USER/software/Red Hat, Inc./cygwin/mounts V. System Table
HKEY_LOCAL_MACHINE.
POSIX
The root path/points to the system partition by default, but you can use the mount command to re-point to any path in the Windows file system. Cygwin generates POSIX path from Win32 path
Always use the longest prefix in the Mount table. For example, if C: Is Installed in/C and/at the same time, cygwin will convert C:/Foo/bar to/C/Foo/bar.
If the mount command is called without any parameters, the current set of installation points of cygwin will be listed. In the following example, drive C is a POSIX root, and drive D is mapped to/d. In this example, the root is a system-wide installation point, which is visible to all users, and/D is only visible to the current user.
C: \> Mount
F: \ cygwin \ bin on/usr/bin type system (binmode)
F: \ cygwin \ Lib on/usr/lib type system (binmode)
F: \ cygwin on/Type System (binmode)
E: \ SRC on/usr/src type system (binmode)
C: On/cygdrive/C type user (binmode, noumount)
E: On/cygdrive/E type user (binmode, noumount)
You can also use the mount command to add a new installation point and use umount to delete the Installation Point.
When cygwin
When a Win32 path cannot be converted to a POSIX path based on an existing installation point, cygwin will automatically convert it to one under the default POSIX path/cygdrive.
For example, if cygwin accesses Z: \ Foo, And the Z disk is not in the installation table, Z: \ will be automatically converted to/cygdrive/Z.
You can assign special properties to each installation point. The automatically installed partitions are displayed as "Auto. You can also select "textmode" or "binmode" as the installation point. This attribute determines whether the text and binary files are processed in the same way.
4.1.3 other path information
The cygpath tool provides the ability to convert win32-posix path formats in shell scripts.
The environment variables home, path, and LD_LIBRARY_PATH will be automatically converted from Win32 to POSIX when the cygwin process starts (for example, if the installation from this Win32 path to POSIX path exists, c: \ cygwin \ bin to/bin ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.