Installing the Intel Compiler on Ubuntu Linux
Most of my regular readers probably know by now that I am developing OpenMP-codes for work. I am also using Linux, more precisely Ubuntu Linux (even more precisely: Kubuntu Linux 6.10). When it comes to compilers for this platform, the Intel Compiler is one of the few affordable choices available – at least if you need OpenMP-support. Affordable in this case used to mean free for private use, cheap for academia and very reasonably priced for everyone else. I am being told by my students that Intel has changed that and the compiler is no longer free for private use, only an evaluation license valid for 30 days is available. I find this decision unfortunate, but of course I don’t know the logic behind it.
Competition is on the horizon, as the Sun compiler for x86/Linux is already in beta (will be free as far as I know). GCC will also include support for OpenMP in its next version 4.2, to be released some time next year – and this one is even free as in speech. The Portland Compiler is also available (although not free).
But this is not the topic of this article, instead I would like to tell you about how to install the Intel Compiler on a Debian-based system. Installation of this compiler used to be a real pain. There is an installation-guide still available online. It’s for Fortran, but used to work for C/C++ as well. It involves converting the rpm-packages with alien and for AMD64-based systems even messing around with these packages. Not too much fun, especially since it took a long time to do and was the primary reason I used to not update our compiler too often.
With the newest packages, the situation has changed. Although Ubuntu or Debian are still not officially supported, it is now possible to install the compiler using these steps:
- download the package (it’s a tar.gz-file)
- unpack it (tar -xvzf filename.tar.gz)
- sudo ./install.sh
- now simply find your way through the installer (should not be too hard) and it will happily install the compiler into a subdirectory of /opt (/opt/intel/cc/9.1.044/ in my case, but if you have a different version the directory will also be slightly different, so be sure to adapt the additional instructions below if needed)
- Party!
If all goes well, you should have an icc-binary in /opt/intel/cc/9.1.044/, which you can test by calling
- $ /opt/intel/cc/9.1.044/bin/icc -V
This should spit out some version information. What you cannot do (yet) is call the compiler from every directory since it is not yet in your path. Also, compiled programs need to be able to find the libguide.so-runtime library. There are multiple ways to solve these issues, probably the easiest one is to add the following to your ~/.bashrc (and ~/.profile if you want to make sure it is called in any case):
- export PATH=$PATH:/opt/intel/cc/9.1.044/bin/icc
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel/cc/9.1.044
After that, the compiler should work correctly from any location in your directory tree.
Troubleshooting
This section lists some of the things that can go wrong and what can be done about them.
Library Issues
First of all, sometimes the compiler complains about missing g++ library versions (or something like that). With the current version of the compiler (9.1.044), this does not happen here anymore, but if it happens to you, try adding a LC_ALL=C in front of your compiler-command, e.g. to compile a simple hello-world program, do this:
- LC_ALL=C icpc hello_world.cpp -o hello_world
If the compiler suddenly starts to work then, you may consider placing this simple wrapper script in e.g. /usr/local/bin:
- !/bin/bash
- # this is a wrapper around icc, required to correctly compile any program with it
- # export GXX_INCLUDE=/usr/include/c++/3.4
- LC_ALL=C /opt/intel/cc/9.1.044/bin/icpc $*
Call the script icpc and make sure it is executable. A similar script may be needed for icc (although to be honest, I have never noticed any difference in between the two – it is recommended that you use icc to compile C-programs and icpc to compile C++-code, but it works the other way around just as well for me).
Note also the commented line where GXX_INCLUDE is set. Try uncommenting it if LC_ALL=C does not help (of course, make sure to set it to a path that actually exists).
Alien or RPM
If you happen to have the alien-package installed (or RPM for that matter), you need to do a couple additional steps after step 2 of my original installation instructions (found in the ever helpful ubuntu-forums):
- change into the resulting directory/data (for the C/C++ compiler: cd l_cc_c_9.x.abc/data )
- edit install_cc.sh and search for the first occurence of RPM_NOT_FOUND=$?
- change it to RPM_NOT_FOUND=1 – this makes sure the installer does not ask the RPM-database to verify your glibc-version, which will break if you have the alien-package installed (because in this case, you will have an RPM-database, created by alien, that is empty)
- cd ..
- proceed with step 3 of my original instructions
Shell-Problems
If you look inside /opt/intel/cc/9.1.044/bin/icpc you will notice, that it is merely a shell-script that calls the actual binary. It wants to be executed using /bin/sh (as can be seen on the first line).
If you are on Ubuntu 6.10, your /bin/sh-symlink most likely points to /bin/dash. The Ubuntu-developers hope to save some boot-time with this transition (it used to point to /bin/bash), unfortunately it breaks the icpc and icc-scripts, as well as the installer-scripts (data/install_cc.sh) of the Intel Compiler (because they use export -N, which is only supported on bash and not on POSIX sh) . I took the easy way out and changed the symlink back to /bin/bash for the time being, but of course you can also change #!/bin/sh in the Intel Compilers scripts to #!/bin/bash (I am not sure exactly in how many files you have to change this, there may be more than the two I have mentioned – as I said, I took the easy way out). This is a bug in the Intel Compiler and needs to be fixed, though and I will file it with their premium support shortly, along with the RPM_NOT_FOUND-fix described above.
Looking at all the steps involved, the installation is still not exactly what I would call easy. However, things are improving and I thought it was worth having this short guide in one place.