Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiplatform C++ cross-compiler

How can I build a cross-compiler for a C++ library to target many platforms on a single build server?

The cross-compiler should be able to build the library for (at least) {Windows 7, Mac OS X, Ubuntu 11.04} × {32 bit, 64 bit} × {Debug, Release}. I don't care if the whole build from scratch takes forever or if the gcc binary is 1 GB. If the cross-compiler cannot be a single executable, what is the workflow I should use to compile (and recompile) my library?

The host machine would be a Ubuntu 11.04.

like image 690
Warren Seine Avatar asked May 12 '11 15:05

Warren Seine


People also ask

Can Msvc cross compile?

Build supports cross compilation with the gcc and msvc toolsets. For the complete list of allowed opeating system names, please see the documentation for target-os feature. When using the msvc compiler, it's only possible to cross-compiler to a 64-bit system on a 32-bit host.

What is cross-compiler in C?

A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a PC but generates code that runs on an Android smartphone is a cross compiler.

Are C programs cross-platform?

The language C itself is cross-platform, because you don't directly run C code on machines. The C source code is compiled to assembly, and assembly is the platform specific code. The only non cross-platform part are the compilers and the resulting assembly.

Is GCC a cross-compiler?

Explanation: GCC, a free software collection of compilers, also can be used as cross compile. It supports many languages and platforms.


1 Answers

Building cross-compiler is quite well covered in OSDev Wiki. For Windows, you can use mingw packages in your distro's repository

like image 155
Erbureth Avatar answered Oct 03 '22 10:10

Erbureth