Cygwin User Guide

xiaoxiao2021-03-06  75

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, and the famous ECOS is now available). 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 improved 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 settings Cygwin

3.1 Installation

To install the online version of Cygwin, you can

Http://cygwin.com, click on "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 Environmental variables

You should set some environment variables before starting Bash. 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 set it to TTY under the DOS box without setting Cygwin or using the following format in the DOS box.

C: /> set cygwin = Tty Notitle Glob

The PATH variable is used by the Cygwin application as a list of paths to search for identity files. 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. Examples are as follows: regtool -i set / hklm / software / cygnus / solventions / cygwin / heap_chunk_in_mb 1024REGTOOL -V LIST / HKLM / SOFTWARE / CYGNUS / SOLUTIONS / CYGWIN4 uses 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 a local naming system. In the UNC, we don't have to care about the file on what disk (or volume), do not care about this disk (or volume) where the server is located. We can access the file in the following format. : // Server Name / Shared Name / Path / File Name Shared Name Sometimes it is also called a logical ID of the volume or storage device in which the file is located, but the purpose of using it is to allow the user to care about these volumes or storage devices. ) 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.

转载请注明原文地址:https://www.9cbs.com/read-108837.html

New Post(0)