Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

How to call icc when using QT? The default complier is gcc

robbymanutd
Beginner
576 Views
I want to compile a QT project with icc. But the default compuler is gcc. What should I do to modify the default compiler?

Just now I download icc and install successfully. But in terminal there is no command of "icc". The icc binary is in /opt/intel/... directory. What should I do to call this icc when using QT?

Thanks
0 Kudos
1 Reply
dpeterc
Beginner
576 Views
Quoting robbymanutd
I want to compile a QT project with icc. But the default compuler is gcc. What should I do to modify the default compiler?

Just now I download icc and install successfully. But in terminal there is no command of "icc".
The icc binary is in /opt/intel/... directory. What should I do to call this icc when using QT?


For making the icc command work in your shell, you need to add the compiler configuration to your shell initialisation scripts. For bash I do it by adding the line
source /opt/intel/Compiler/11.1/072/bin/iccvars.sh ia32
into .bashrc
This is described in the compiler release notes.

For compiling qt programs with icc instead of gcc, it is slightly more complicated.
Basically, you need to replace gcc with icc in your qmake configuration files.
To me, qt compilation process looks like a total mess, an overly complicated mash-up.
If you use qt designer, you can probably configure it there.
I maintain one qt3 based open source project, which can be compiled both by gcc as with icc.
So you can look a the source code and see how I solved this problem.
Basically, I have two qmakespec locations with relative configuration files, one for gcc and one for icc.
All the differences are concentrated in qmake.conf
while the environment variable QMAKESPEC will define the location of qmake.conf

ArahPaint4.1b source

If you want to explore this you can first compile the program and libraries by following the instructions, and then do
cd main
makeClean
makeReleaseIcc

Maybe my solution is not optimal, but it works for me quite well. So I simply use two separate make configurations for the two compilers. Icc and gcc, while being somewhat compatible, will not generate best code, if you use the same compile options. That is, at least one of them will make sub-optimal code.
0 Kudos
Reply