Skip to content

Instantly share code, notes, and snippets.

@AlainODea

AlainODea/hello.c

Last active Mar 16, 2016
Embed
What would you like to do?
Cross-compiler from x86_64 Linux to x86_64 Illumos on Ubuntu (works for Hello World and possibly more)
#include<stdio.h>
main()
{
printf("Hello World");
}
#!/bin/bash
export TARGET=x86_64-sun-solaris2.11
export PREFIX=$HOME/Documents/gcc/cross/$TARGET
export SYSROOT=$PREFIX/sysroot
export PATH=$PATH:$PREFIX/bin
export SCRATCH=$HOME/Documents/gcc/scratch
export BINUTILS=binutils-2.23.2
export GCC=gcc-4.7.3
sudo apt-get install texinfo binutils build-essential libgmp-dev libmpfr-dev libmpc-dev
mkdir $PREFIX
mkdir $SYSROOT
pushd $SYSROOT/
ssh root@ns2 "pkgin -y up && pkgin -y ug && pkgin -y in gmp"
ssh root@ns2 "tar -cf - /usr/include" | tar -xvf -
ssh root@ns2 "tar -cf - /opt/local/include" | tar -xvf -
ssh root@ns2 "tar -cf - /opt/local/gcc47/include" | tar -xvf -
ssh root@ns2 "tar -cf - /lib" | tar -xvf -
ssh root@ns2 "tar -cf - /usr/lib" | tar -xvf -
ssh root@ns2 "tar -cf - /usr/gnu/lib" | tar -xvf -
mkdir $SCRATCH
pushd $SCRATCH/
wget http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.gz
tar -xvzf $BINUTILS.tar.gz
mkdir $SCRATCH/build-binutils
pushd $SCRATCH/build-binutils/
../$BINUTILS/configure -target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT -v
make all && make install
popd
wget http://ftp.gnu.org/gnu/gcc/$GCC/$GCC.tar.gz
tar -xvzf $GCC.tar.gz
mkdir $SCRATCH/build-gcc
pushd $SCRATCH/build-gcc/
../$GCC/configure --target=$TARGET --with-gnu-as --with-gnu-ld --with-gmp \
--with-mpfr --with-mpc --prefix=$PREFIX --with-sysroot=$SYSROOT \
--disable-libgcj --enable-languages=c,c++ -v
make all && make install
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.