Cross-Platform – Using Intel C/C++ Compiler on Linux for Windows Object Files

ccompilercross platformopen source

Why?

Depending on your source the Intel compiler is likely or most definitely the compiler generating the fastest executables for the x86 architecture (5 to 100 % execution time improvement).

Intel offers its compilers for Linux under a non-commercial license for free (I think I read it is free somewhere on their page: Intel – Non-Commercial Software Development).
There is also a free non-commercial license for students, but this license is not applicable although tools are offered for all three major operating systems (link dropped due to reputation restriction).

Goal

I (as a non-student) would like to be able to use the Intel compilers for possible execution speed improvements under the non-commercial license to compile object files that can be linked to create executables and dynamic link libraries for Windows (and possibly OS X)

More Details:

What I inferred from this document is that the Intel compilers create object files that are compatible to the dominant compilers of the platform.

Sub-questions:

  1. What are the object file formats of gcc, g++, cl, mingw32, icc, icpc, and icl on Windows and Linux (current versions)?
  2. Could parts of the mingw32 cross-compiler toolchain be used to accomplish the goal?
  3. Am I right that the metadata in the generated object files is the main issue?

ad 2:
mingw32-objcopy seems to be able to convert the Intel compiler output on Linux (presumably ELF) to Microsoft-compatible COFF (with the possible exception of relocateable object files). Could someone confirm that this actually works (for non-trivial applications), please?

Best Answer

It is possible to create Windows executables on a Linux build machine by using a cross-compiler. But, Intel does not provide such cross compilers.

To answer the sub-questions:

What are the object file formats of gcc, g++, cl, mingw32, icc, icpc, and icl on Windows and Linux (current versions)?

The format for the object files is effectively determined by the operating system (or rather, the compiler used to build it). For Windows, this is the Portable Executable (PE) format and for Linux the ELF format.

Could parts of the mingw32 cross-compiler toolchain be used to accomplish the goal?

No. The relevant part is the code generator, which is both the part responsible for generating the right object format and the part on the Intel compilers that gives their generated code the speed edge.

Am I right that the metadata in the generated object files is the main issue?

No. It is one issue, but there are more. A more fundamental problem is the potential difference in how parameters are passed to the kernel and/or standard library. IIRC, those conventions are different between Windows and Linux.

Related Topic