Introduction
Intel Parallel Studio provides pre-configured bat to run command line interface using Windows CMD. The command is called 'icl'. To some, this is satisfactory. To me, I need a better shell.Cygwin satisfies my need for a UNIX shell. This post is about setting up a Windows system to successfully compile a simple code using Cygwin and icl, Intel C++.
Largely, I had two issues: one minor, quality-of-life issue, the other critical.
Quality-of-Life issue
The minor issue is that I wanted to simply double-click on the icon to open up a console with appropriate environment. The provided bat file does that, but for CMD. I wanted to gear that toward Cygwin bash environment. The obvious way is to open up the CMD through the bat, and then execute Cygwin.bat from the Cygwin installation folder.To have one-click icon to open up a prepared Cygwin bash console, we must provide appropriate arguments to the shortcut.
Method
- Locate the Intel-provided shortcut file called "Compiler 19.0 for Intel 64 Visual Studio 2017 environment" by going through the start menu and opening the folder location of the shortcut
- Make a copy of the shortcut and rename it appropriately (e.g. "Cygwin - Compiler 19.0 for Intel 64 Visual Studio 2017 environment")
- Right-click on the new shortcut and adjust the address
- Add "&" character in the argument to add a new command
- Add, after &, a command to execute Cygwin.bat
- The end result will look something like the following:
C:\Windows\System32\cmd.exe /E:ON /V:ON /K ""C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\bin\ipsxe-comp-vars.bat" intel64 vs2017 & C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico - "
- Execute and see two windows open: first, CMD windows showing environment being set up, then Cygwin console with the bash promp.
Critical Issue
The second issue, if unaddressed, makes the process unusable.Symptom
Given a cpp file called test.cpp, compilation is done by icl test.cpp
This will generate test.obj and proceeds to link the file to the output file.
The link process fails.
The link process fails because of the path issue; essentially, wrong and incompatible link
is called, causing the compilation process to fail.
Workaround
The issue is the path. The commandlink
exists in /usr/bin
of cygwin, as well as in the Intel Parallel Studio installation. When icl
is used, like any command in shell, the bash goes through its PATH to find the first match of the command. In the default Cygwin installation, /usr/bin
appears before the Windows-imported path. As such, link
from GNU Coreutils is selected over the Intel compiler's. Therefore, a simple solution is the reverse the order of path such that Windows-imported path appears before Cygwin native paths.
To do so, edit the /etc/profile
and change the PATH variable:
PATH="/usr/local/bin:/usr/bin${PATH:+:${PATH}}"
Now, the correct link
will be used to complete the compilation process.
Caveat
This method will now cause Cygwin to call wrong command if there are other commands with the same name in Windows installation. Possible solution is to create a script that will temporarily change the PATH, run icl, and change the PATH back. I will need to understand how Cygwin imports PATH from Windows to implement this.'UPDATE 20180913
To implement the scenario in Caveat, I created a new shell variable, PATH_INTEL in/etc/profile
right before the line with PATH and assigned the appropriate values favorable to icl and kept PATH to its original that placed cygwin bin first and Windows commands later. I also created a script called icl.sh that switched PATH before icl $* and switch it back afterwards. I then finally created an alias for icl that points to script instead. Now, the PATH does not interfere with the rest of the command while correct PATH is used while icl is being run.
Comments
Post a Comment