Source:http://www.cnblogs.com/rocky_yi/archive/2009/12/08/cygwin.html rocky_y
Many classic algorithms are often implemented in C + + under Linux, for the long-term windows development of the hard-working public, want to see the operation of these algorithms have to pay a little effort. Today, a night to fix this, write the implementation method and everyone share.
First step: Download and install the new Cygwin software. The official website of the software: http://cygwin.com/
The role of Cygwin software is to allow Windows to have software for unix-like environments. So, a compiler like GCC will naturally be included inside. However, for developers, Cygwin is a development environment. And for the user, Cygwin is a running environment.
Attention:
1. In order to compile C + + or C programs, the next step in selecting a component is to select the Gcc-core,gcc-g++,make under the Devel option and the Glib2,glib2-devel,glib2-runtime under the Lib tab.
2. In order to improve the network download speed, we recommend to download the website NetEase Mirror site: http://mirrors.163.com/
Step Two: Modify the Cygwin.bat file.
Locate the Cygwin. bat file under the Cygwin Project installation directory and open it with Notepad. Modified to the following form:
@echo off
C:
Set Cygwin=tty notitle Glob
Set Path=%path%;c:\cygwin\bin;c:\cygwin\sbin;c:\cygwin\usr\bin;c:\cygwin\usr\sbin;c:\cygwin\usr\local\bin
Set Ld_library_path=c:\cygwin\lib;d:\cygwin\usr\lib;c:\cygwin\usr\local\lib
ChDir C:\cygwin\bin
Bash--login-i
The red part is the newly added part, note that the path inside is changed to your own installation path.
Special attention:
for WIN7 64-bit Systems , the default Cygwin is installed in the C:\cygwin64\bin directory, so Cygwin.bat is modified as follows:
@echo off
C: set cygwin=tty notitle glob
Set path=%path%;c:\cygwin64\bin;c:\cygwin64\sbin;c:\cygwin64\usr\bin;c:\cygwin64\usr\sbin;c:\cygwin64\usr\local \ Bin
Set Ld_library_path=c:\cygwin64\lib;d:\cygwin64\usr\lib;c:\cygwin64\usr\local\lib
ChDir C:\cygwin64\bin
Bash--login-i
Step three: Compile the software using g++ in Cygwin.
Under the Cygwin installation directory, run Cygwin.bat to start the Cygwin environment. Use cd/cygdrive/after environment start ... Go to the folder where your project is located (...). Represents the project directory, such as: cd/cygdrive/d/testproject/). After entering the directory you can use the g++ command to compile the code, the specific use of the g++ command can be learned by typing the g++--? command. General online projects have a makefile file, if you download the project happens to have this file, it is fortunate that you directly in the Ygwin environment to enter the make command to compile the entire project. So far the software should have been compiled successfully.
Fourth step: Run the software.
Running the software is a command in the following form:./testproject-parameter. In addition, if you need to enter data in the Cygwin environment, CTRL +d in the Linux environment indicates the end of the input (Ctrl + Z and press Enter in Windows).
How do I compile Code for Linux UNIX in Windows (using Cygwin)?