I'm running Mac OS X 10.5.8 and want to compile for target CentOS 5.3 with GCC 4.1.2. How could I:
Any help is greatly appreciated!
For instance when installing GCC, the GNU Compiler Collection, we can use --target= target to specify that we want to build GCC as a cross-compiler for target . Mixing --build and --target , we can cross-compile a cross-compiler; such a three-way cross-compilation is known as a Canadian cross.
Your simplest solution is to just run CentOS 5.3 in a VM (e.g. Sun VirtualBox). This requires minimal setup, has quite reasonable overhead (assuming an Intel Mac), and you'll be able to actually test and debug what you are building.
If you really insist on cross-compiling, you must build a cross-compiler. Instructions are here and here, but beware: it will likely take you several days to get it right, and then you'll still need a VM to test the result, so I don't see any point in doing it that way.
Nowadays you can probably do it with Docker for Mac, I didn't test it because I have no mac. Docker basically creates a Linux VM and provides some nice-to-have functions.
docker run -ti centos5.3 /bin/bash
(search the official Docker Hub for your desired target)sudo yum group install "Development Tools"
)docker ps -a
to obtain your container iddocker commit [id] centos:build
Now you can use your created build environment for CentOS builds.
docker run -it --mount type=bind,source=$(pwd),target=/mnt centos:build /bin/sh -c "cd /mnt && bash"
gcc ...
or ./configure
or make
or ninja
or whatever to do your buildWith docker you can use your beloved terminal with your familiar theme and keymap. Furthermore it most probably will consume less resources for startup and while running.
If your app is graphical and you test it by using interaction with its GUI I guess a VM is still a better option (see @employed-russian's solution).
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