2012年7月14日

A method for using Intel Compilers for Windows* under the Cygwin* bash shellSubmit New Article February 19, 2010 7:00 PM PST Introduction Cygwin* (http://Cygwin.com/) is a popular choice among users seeking a Linux*-like working environment under Windows*. Cygwin* is not an officially supported environment by the Intel® C++ and Intel® Visual Fortran Compilers for Windows* (http://software.Intel.com/en-us/Intel-compilers/); however, setting up the Intel® Compilers for Windows* for use under the Cygwin* bash shell environment is very easy and the compilers are very compatible, functional, and usable. This article discusses one method for making the Intel® C++ and Fortran Compilers for Windows* usable under the Cygwin* bash shell. The details herein apply to basic compiler usage scenarios and may also apply to some complex compiler usage scenarios; however, some complex usage scenarios involving automated build systems, or makefiles, or non-C: drive locations, may require additional customized setup. Some Required Setup The basic requirement to use the Intel® Compilers for Windows* under a Cygwin* bash shell environment involves setting up the appropriate bash shell environment variables. There are a variety of methods available to satisfy this basic requirement. This article discusses only one method of starting the Cygwin* bash shell under a Windows* command prompt window that has been pre-initialized to use the Intel® compilers. This method leverages the Intel® compiler setup scripts (iclvars.bat, ifortvars.bat) for setting the appropriate environment variables that the Cygwin* bash shell then inherits. Before getting started using the Intel® Compilers for Windows* under the Cygwin* bash shell, users must complete a one-time essential setup to ensure the Intel® compilers use the required Microsoft Visual Studio* linker (link.exe). To ensure the Intel® compilers use the Microsoft* linker by default, some additional specific setup is necessary. Here again, there are a variety of methods available to satisfy this requirement, but this article currently only discusses one method of using the Cygwin* bash shell alias feature. To establish the needed Intel® compiler (ifort and icl) shell aliases, users must add the shell aliases below to their private .bash_profile (found in their home directory): alias ifort='ifort -Qlocation,link,"$VCINSTALLDIR/bin"' alias icl='icl -Qlocation,link,"$VCINSTALLDIR/bin"' A primary convenience of this alias method is their usability with any Intel® compiler release, with both the IA-32 and Intel® 64 architecture specific compilers, and any Microsoft Visual Studio* installation. Also, the Microsoft Visual Studio* version used (via $VCINSTALLDIR) matches that version specified (during the Intel® compiler installation) for association with command-line usage of the Intel® compiler. Creating a Working Environment With the aliases established in .bash_profile, users are ready to establish the Cygwin* bash shell environment to use the Intel® Compilers for Windows*. This is accomplished through two simple steps; the first is opening the Intel® compiler pre-initialized command prompt window for the desired Intel® compiler; the second is starting the Cygwin* bash shell. Step 1: Open Intel® Compiler pre-initialized Windows* command prompt window This step is accomplished using a short-cut provided in the Intel® compiler program group (via the Start button) to create a Build Environment window for command-line usage of the Intel® compiler. This method opens a Windows* command prompt and sets the environment variables specific to using the Intel® compiler. For the Intel® Compilers for Windows* 11.1 release, depending on the available installed compilers, the program group items available will be like: Intel(R) Software Development Tools > Intel(R) Visual Fortran Compiler Professional 11.1.xxx > Fortran Build Environment for applications running on {IA-32 or Intel® 64} Intel(R) Software Development Tools > Intel(R) C++ Compiler Professional 11.1.xxx > C++ Build Environment for applications running on {IA-32 or Intel® 64} There is a nice convenience that the Intel® Compilers for Windows* 11.1 release offers under configurations where both the Intel® C++ and Fortran compilers are installed. When both the Intel® C++ and Fortran compilers are installed, both (like architecture) compilers become available under the Cygwin* bash shell through use of only one of the architecture specific compiler short-cuts mentioned above. This is made possible by the use of a common default installation folder by both the Intel® C++ and Fortran compilers in the 11.1 release. Execute the appropriate compiler short-cut to open the pre-initialized Build Environment command prompt window and then proceed to Step 2. Step 2: Start the Cygwin* bash shell This step is accomplished simply by executing the Cygwin* batch initialization script (Cywin.bat) under the Intel® compiler pre-initialized command prompt window opened in step 1. Assuming the default Cygwin* installation (C:\Cygwin) was used, in the Intel® compiler pre-initialized command window, enter the command below followed by carriage return: C:\Cygwin\Cygwin.bat This command will initialize and start execution of the Cygwin* bash shell under the Intel® compiler pre-initialized command prompt window. Depending on the user's Cygwin* setup, the bash shell prompt (typically $) should appear. At this stage, the Cygwin* bash shell is now running and the Intel® compilers are ready. Users are encouraged to enter the command alias to ensure the compiler aliases discussed earlier were created accordingly and try trivial Fortran and C/C++ sample programs to ensure the compilers are functional. Some General Usage Information The information in this section is not intended to be a comprehensive discussion of the existing usage limitations or conveniences with using the Intel® Compilers for Windows* under the Cygwin* bash shell. There may be limitations or conveniences that were not known by the author when this article was written; therefore, the section may be updated as new details emerge. A brief word about Intel® Compiler options and the conveniences available Intel® Compilers for Windows* accept the traditional Windows* forward-slash style compiler options but they also accept Windows* options using a Linux-style hypen (-). Both forms of option are usable under the Cygwin* bash shell environment. Related testing in this area was not exhaustive; therefore, some Windows* specific options may not function properly when used with the hyphenated form. For example: Intel® Compilers for Windows* accept the following Windows*-style and Linux*-style compiler options and treat them identically. /O1 is identical to -O1 /Qipo is identical to -Qipo Users are not required to use Linux*-style (hyphen) compiler option syntax. Again, either form is usable under the Cygwin* bash shell environment. A brief word about paths and the conveniences available First, always remember the Intel® Compilers for Windows* are Windows*-based. Their availability under a Linux*-style environment does not change their inherent understanding of Windows*-style paths. So when in doubt or to help avoid issues, use double-quoted (" ") Windows*-style relative or absolute paths (e.g. "C:\myprogram\include" ) on the command-line. Unfortunately, making the Intel® compilers available under the Cygwin* bash shell also does not automatically enable complete understanding of Linux*-style (forward slash) paths. Linux*-style relative paths appear to be usable overall on the compiler command-line, but limitations exist with Linux*-style absolute paths in some uses. Under Cygwin*, absolute paths can become further complicated with the addition of the Cygwin*-style /cygdrive/ designation (optional for some C: drive references but required for all non-C: drive references). The Intel® compilers cannot parse any path of the form /cygdrive// However, they can parse a very close alternative of :/ For example: The Intel® compilers accept the path c:/sample_program/include but not the path /cygdrive/c/sample_program/include. This alternate absolute path name is accepted for paths specified with the -I option, the -o option (with limitations explained below), and for the source file path. Related testing in this area was not exhaustive; therefore, some forms of non-Windows* specific paths may exist that are not accepted. A brief word about the -o option The -o option is only partially supported by the Intel® Compilers for Windows*. The usage limitations include: - There must be a space between the "o" and the input argument. (e.g. -o myexe is valid; -omyexe is invalid) - It does not function when used with -c (compile-only); thus it cannot be used to name individual intermediate object files (e.g. .obj). - It is only available for naming the final executable - The final executable name always includes the .exe file extension A brief word about using the Intel® Performance libraries or VNI's IMSL* libraries The Intel® Professional Compilers for Windows* 11.1 Release includes the following Intel® performance libraries: Intel® Threading Building Blocks (TBB) Intel® Integrated Performance Primitives (IPP) Intel® Math Kernel Library (MKL) VNI's IMSL Fortran Library for Windows* is available with the Intel® Visual Fortran Compiler Professional Edition for Windows* with IMSL* product. Installation of these libraries includes modification of appropriate system environment variables (e.g. PATH, LIB, INCLUDE) and specific system-wide special purpose environment variables; therefore their use with the Intel® Compilers for Windows* under the Cygwin* bash shell requires no special user action because the appropriate environment variables become available under the Cygwin* bash shell as a by-product of the steps outlined above for Creating a Working Environment. A brief word about using pre-11.1 versions of the Intel® Compilers for Windows While the information provided in this article is specific to the Intel® C++ and Fortran Compilers for Windows* 11.1 release, it in large part applies to using pre-11.1 versions of the Intel® Compilers for Windows*. The only known complication involves configurations where both the Intel® C++ and Fortran compilers are installed. For configurations where only one of either the Intel® Fortran compiler or Intel® C++ compiler is installed, the information applies as written. Under configurations where both the Intel® Fortran and C++ Compilers for Windows* are installed, an extra step is required within step 1 to make both compilers available under the Cygwin* bash shell requires. Under step 1, an additional step is required to execute the appropriate Intel® compiler setup script for the compiler's whose short-cut was not used in step 1. For example: If the short-cut for the Intel® Fortran Compiler for Windows* is chosen to create a Build Environment window discussed in step 1, then as extra step the Intel® C++ compiler initialization script (e.g. iclvars.bat) must be executed manually under this new Build Environment command prompt window to further initialize environment variables specific to the Intel® C++ compiler before proceeding to step 2. Summary In summary, setting up the Intel® Compilers for Windows* to use under the Cygwin* bash shell environment is very easy and the compilers are very compatible, functional, and usable. This article only intends to discuss one method to setup and use of the Intel Compilers for Windows* under the Cygwin* bash shell. There are of course alternative methods available, some of which may be discussed in future articles. The information provided in this article is intended solely as an aid to helping users setup and use the Intel® C++ and Fortran Compilers for Windows* under the Cygwin* bash shell. Cygwin* is not an officially supported environment by the Intel® C++ and Fortran compilers for Windows. The Intel® C++ and Fortran compilers for Windows* are not formally tested or validated for use under Cygwin*; therefore the information herein does not imply any formal support or warranty for such. Please share any experiences or usage tips for using Intel® Compilers for Windows* under Cygwin* in the space provided below. © 2009, Intel® Corporation. All rights reserved. Intel®, the Intel® logo, Intel® Atom, and Core are trademarks of Intel® Corporation in the U.S. and other countries. *Other names and brands may be claimed as the property of others. [DISCLAIMER: The information on this web site is intended for hardware system manufacturers and software developers. Intel does not warrant the accuracy, completeness or utility of any information on this site. Intel may make changes to the information or the site at any time without notice. Intel makes no commitment to update the information at this site. ALL INFORMATION PROVIDED ON THIS WEBSITE IS PROVIDED "as is" without any express, implied, or statutory warranty of any kind including but not limited to warranties of merchantability, non-infringement of intellectual property, or fitness for any particular purpose. Independent companies manufacture the third-party products that are mentioned on this site. Intel is not responsible for the quality or performance of third-party products and makes no representation or warranty regarding such products. The third-party supplier remains solely responsible for the design, manufacture, sale and functionality of its products. Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. *Other names and brands may be claimed as the property of others.]