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.
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.
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.
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.
Explanation: GCC, a free software collection of compilers, also can be used as cross compile. It supports many languages and platforms.
Building cross-compiler is quite well covered in OSDev Wiki. For Windows, you can use mingw packages in your distro's repository
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With