Multiplatform C++ cross-compiler

2019-04-28 18:10发布

问题:

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.

回答1:

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



回答2:

Windows host + TeamCity + GCC (mingw) + Gnu Make (or complementary build script solution) + MSVC8/9

You can have teamcity automate the building of everything for you, GCC will let you build targets in all DBG/REL, 32/64 bit, MacOS/Linux permutations. MSVC8/9 test for cross-compiler compatibilities.