According to Cygwin User Guide Translation, I hope to help everyone. There is a mistake clear. 1 Introduction Cygwin is a UNIX simulation environment running on a Windows platform, which is the free software developed by Cygnus Solutions (the company has developed a lot of good things, famous and ECOS, but it has been acquired by Red Hat). It is very useful for learning UNIX / Linux operating environments or transplants from UNIX to Windows, or for certain special development work, especially using GNU tools to embed system development on Windows. As embedded systems are developing in China, more and more developers have interested in Cygwin. This article will be introduced. 2 Mechanism CYGNUS first improves the development tools such as GCC, GDB, GAS, enabling them to generate and explain the Win32 target file. Then they want to transplant these tools to the Windows platform. One solution is based on Win32 API's source code for these tools, which clearly requires a lot of work. Therefore, they have taken a different way - they wrote a shared library (that is, Cygwin DLL), encapsulated in the Win32 API (such as Fork, Spawn, Signals, SELECT, SOCKETS, etc.) That is, they wrote an analog layer of a UNIX system library based on Win32 API. This way, just connect these tools and this shared library together, you can use the cross-compiler on the UNIX host to generate a toolset that can run on the Windows platform. Based on these development tools on the Windows platform, Cygnus gradually puts other tools (almost no need to modify the source code, just modifying their configuration scripts) software transplanted to Windows. This way, running Bash and development tools on the Windows platform, user tools, feel like working on UNIX. For a more detailed description of Cygwin implementation, please refer to
Http://cygwin.com/cygwin-ue-net/highlights.html
. 3 Installation Set Cygwin 3.1 Installation To install the network version of Cygwin, you can
http://cygwin.com
, Click "Install Cygwin Now!". This will download a GUI installer called Setup.exe and use it to download a complete Cygwin. The instructions of each screen can be easily installed. 3.2 Environment variables Before starting Bash, you should set some environment variables. Cygwin provides a .bat file, which has set the most important environment variable. It is the safest way to start Bash by it. This .bat file is installed under the root of Cygwin. This file can be edited freely. Cygwin variables are used for a variety of global settings for Cygwin runtime systems. At the beginning, you can do not set Cygwin or use the following format to use the following format in the DOS box to TTY C: /> Set Cygwin = Tty Notitle Glob path variable by the Cygwin application as a path list of search instructions . When a Cygwin process is started, the variable is converted from the Windows format (E.G. C: / Winnt / System32; C: / Winnt) into UNIX format (E.G., / WinNT / System32: / Winnt). If you want to use the Cygwin toolset when you don't run Bash, the PATH should include x: / cygwin / bin, where x: / cygwin is the CygWin directory in your system. Home variable is used to specify the primary directory, it is recommended to define this variable before executing BASH. When the Cygwin process is started, the variable is also converted from the Windows format to UNIX format, for example, the value of HOME on the author's machine is C: / (DOS command set home can see his value, set home = xxx can do Setting), look at Echo $ HOME in Bash, its value is / cygdrive / c. Term variable specifies the terminal. If the US is set to it, it will be automatically set to Cygwin. LD_LIBRARY_PATH is used as a path list of a search .dll file as a search .dll file, which is also converted to UNIX format from the Windows format. Most Cygwin applications do not use DLOPEN, so this variable is not required. 3.3 Changing Cygwin's maximum storage capacity Cygwin program default memory does not exceed 384 MB (Program DATA). This limit does not need to be modified in most cases. However, if you need more actual or virtual memory, you should modify the HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER segment of the registry. Tian family a DWORD key Heap_chunk_in_mb and sets its value to the required memory limit, and the unit is a decimal MB. You can also complete this setting with RegtoE in Cygwin. The examples are as follows: regtool -i set / hklm / software / cygnus / solvention / cygwin / heap_chunk_in_mb 1024 RegtoL -V List / HKLM / Software / Cygnus / Solutions / Cygwin 4 Use Cygwin to talk about the difference between Cygwin and Traditional UNIX systems . 4.1 Mapping path Name 4.1.1 Introduction Cygwin supports Win32 and POSIX-style paths, and the path separator can be a front slash or a backslash. Also supports UNC pathname. (In the network, UNC is a method of determining file locations, using this method user can not care about the physical location of the storage device, which is convenient for users. In Windows operating system, Novell NetWare, and other operating systems have been used This specification is replaced with the local naming system. In the UNC, we don't have to care about the file on what disk (or volume), where you don't care where this disk (or volume) is located.
We can access files in the following format: // server name / shared name / path / file name sharing name is sometimes referred to as a logical ID of the volume or storage device in the file, but the purpose of using it is to let users do not have to care about these The physical location of the volume or storage device. ) Compliance with the POSIX standard operating system (such as Linux) does not have a concept of disk. All absolute paths are starting with a slash instead of a disk (such as C :). All file systems are the subdirectory. For example, two hard drives, one of which are roots, and the other may be under the / disk2 path. Because the programs on many UNIX systems assume that there is a single POSIX file system structure, CygWin specializes in the internal POSIX view of the Win32 file system, so that these programs can run correctly under Windows. In some cases, Cygwin uses this mapping to perform conversion between Win32 and POSIX paths. 4.1.2 Cygwin Mount Table Cygwin is used to map Win32 drives and network sharing paths to Cygwin's internal POSIX directory tree. This is a concept similar to a typical UNIX MOUNT program. For those who are unfamiliar with Unix, the Mount program and the early DOS command Join are very similar, that is, the subdirectory of one drive as another path. Path mapping information is stored in the Cygwin Mount table of the current user, this mount table is in the registry of Windows. Thus, when the user is logged in next time, this information is removed from the registry. The Mount is divided into two, except for each user-specific table, and the system-wide mount table, each CygWin user's installation table is inherited from the system table. The system table can only be modified by a user who has appropriate permissions (administrator). The current user's MOUNT table can be seen under the registry "HKEY_CURRENT_USER / SOFTWARE / Red Hat, Inc./cygwin/mounts v". The system table is HKEY_LOCAL_MACHINE. POSIX root path / default points to system partitions, but you can use the mount command to redirect to any path to the Windows file system. When Cygwin generates a POSIX path from the Win32 path, it always uses the longest prefix in the MOUNT table. For example, if c: is mounted at / c and /, Cygwin will convert C: / foo / bar into / c / foo / bar. If you do not add the mount command, you will collect all columns in the Cygwin's current installation point. Out. In the example below, the C drive is the POSIX root, and the D disk is mapped to / d. In this example, the root is a system-wide mount 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) can also add new installation points using the mount command Use umount to delete mounting points.