How to use various compilers

From Freehackers
Revision as of 23:05, 10 January 2010 by Orzel (talk | contribs) (New page: = Build tools= == cmake == set env variables CC and CXX before starting cmake. Exemple with icc on gentoo using tcsh, starting from the project main dir: setenv CC /opt/intel/Compiler...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Build tools

cmake

set env variables CC and CXX before starting cmake. Exemple with icc on gentoo using tcsh, starting from the project main dir:

 setenv CC /opt/intel/Compiler/11.1/056/bin/intel64/icc
 setenv CXX /opt/intel/Compiler/11.1/056/bin/intel64/icpc
 mkdir build && cd build
 cmake ..
 make

qmake

Check which 'mkspec' you need by looking in $(QTDIR)/mkspecs/, and then use

 qmake -recursive -spec <specname>

The -recursive flag is great if your project was already configured with some other (default) spec file. Without it, only the main directory can be re-configured. Exemples on windows if you want to use the msvc2008 compiler.

 qmake -recursive -spec win32-msvc2008
 nmake

Configuring for mingw32

 qmake -recursive -spec win32-g++
 mingw32-make

If you want to use clang with qt, see the last section 'download'.

Compilers

gcc/g++

This is the default one on all linux distributions and most *BSD ones. Under windows, this is the compiler used by mingw32.

MSVC 2008

Command line tools are available freely from MS site.

ICC

ICC can be downloaded and used under linux for non commercial usage. Beware that there is evidence that icc purposely generate bad code when it detects a non-intel cpu. But if you just want to check against icc C++ parser, you don't mind.

Clang

For c++, I highly suggest using the svn trunk. For C and objective-C, the latest official release is ok. i use CXX=~/svn/llvm/Release/bin/clang++ If you want to use clang with qt, see the next section 'download'.

Download

I created this quick&dirty linux-clang mkspec for linux. You'll have to change the file clang.conf to use your actual path. This is basically a copy of linux-g++ on which i've changed compilers' path. It "works for me" (c), using qt-4.6. Just extract it in your $(QTDIR)/mkspecs