字體:小 中 大 | |
|
|
2007/01/24 03:22:36瀏覽1243|回應0|推薦0 | |
It can be very easy to get confused about these two GCC targets. The binaries
for both targets are produced by GCC and execute in the Windows environment. There are, however, significant differences that are important to understand:
One should use Cygwin GCC when he:
One should use MinGW GCC when he:
Generating MinGW Binaries in a Cygwin Environment Many times, a UNIX-based source distribution comes with 'sh' shell scripts that are essential to the build process. The MinGW distribution does not provide an 'sh' binary, nor does it provide various other binaries that are likely to be called by a shell script. The Cygwin Environment does provide the 'sh' binary as well as just about any other binary a shell script is likely to invoke. For this reason, it is often useful to have Cygwin binaries accessible via the PATH environment variable. A shell script can execute in a Windows command shell as long as the "cygwin" shell binary is explicitly invoked and the Cygwin DLL is in the current directory or is accessible via the PATH environment variable. Of course, if the shell script calls any other "cygwin" binaries, those binaries must also be accessible via the PATH environment variable. The easiest way to ensure that "cygwin" binaries are accessible is to operate from the Cygwin bash shell. The Cygwin bash shell ensures that "cygwin" binaries are accessible by setting the PATH environment variable appropriately. When a command is typed in the Cygwin bash shell, the shell will check to see if the command is a binary file or a shell script and execute it accordingly. This advantage is not available with a Windows command shell. When one wants to generate binaries with GCC, he can do so from any command shell. The Cygwin bash shell is the preferred choice because of the advantages that it brings. The Cygwin bash shell can be used to generate both "cygwin" and "mingw" binaries. When one wants to generate "mingw" binaries from the Cygwin bash shell, he can do so using one of these methods:
The second method is possible because the original developers of Cygwin recognized the need to produce MinGW binaries from a Cygwin Environment. Cygwin GCC recognizes both "cygwin" and "mingw" targets. Cygwin binaries are generated by default. MinGW binaries are generated by passing the -mno-cygwin flag to GCC. The second method is more useful than the first. The tools in Cygwin GCC are, themselves, "cygwin" binaries. The tools in MinGW GCC are, themselves, "mingw" binaries. As such, only the Cygwin GCC tools receive the special translations support provided by the Cygwin DLL. To better understand the Cygwin DLL advantage, consider the following example: many times, shell scripts create symbolic links to files and specify those symbolic links to compiler tools as parameters, e.g. GNU Libtool. If a shell script were to provide a symbolic link to any tool in MinGW GCC, the tool would fail. As a "mingw" binary, the tool would be unable to resolve the symbolic link. A symbolic link is a special file that only the Cygwin DLL is capable of creating and interpreting. Thus, if a symbolic link were specified to a "cygwin" binary, it would be able to interpret the link and follow it to open the correct real file. Using the -mno-cygwin switch with Cygwin GCC in a Cygwin bash shell is the best way to generate "mingw" binaries. The rest of this document focuses on this method. |
|
( 休閒生活|旅人手札 ) |