Thursday, June 28, 2012

How to compile GCC 4.6.3 on Mac OS X

(1) Download Source Code and untar
mkdir -p gcc463
cd gcc463

#get the source
curl -O ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
curl -O ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
curl -O ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
curl -O http://ftp.gnu.org/gnu/gcc/gcc-4.6.3/gcc-4.6.3.tar.bz2

#untar
tar xjf gmp-4.3.2.tar.bz2
tar xjf mpfr-2.4.2.tar.bz2
tar xzf mpc-0.8.1.tar.gz
tar xjf gcc-4.6.3.tar.bz2


(2) Build it
buildgcc463.sh    Select all
#!/bin/bash export CXX=/usr/bin/g++ export CC=/usr/bin/gcc export CPP=/usr/bin/cpp export LD=/usr/bin/ld export RANLIB=/usr/bin/ranlib export AS=/usr/bin/as export AR=/usr/bin/ar GMP="`pwd`/gmp-4.3.2" MPFR="`pwd`/mpfr-2.4.2" MPC="`pwd`/mpc-0.8.1" GCC_SRC="`pwd`/gcc-4.6.3" PREFIX=~/local if [ ! -f $PREFIX/lib/libgmp.dylib ] ; then rm -fr $GMP/build mkdir -p $GMP/build cd $GMP/build echo "configure gmp ..."; ../configure --prefix=$PREFIX --build=x86_64-apple-darwin11 echo "building gmp ..."; make && make install fi if [ ! -f $PREFIX/lib/libmpfr.dylib ] ; then rm -fr $MPFR/build mkdir -p $MPFR/build cd $MPFR/build pwd echo "configure mpfr ..."; ../configure --prefix=$PREFIX --with-gmp=$PREFIX --build=x86_64-apple-darwin11 echo "building mpfr ..."; make && make install fi if [ ! -f $PREFIX/lib/libmpc.dylib ] ; then rm -fr $MPC/build mkdir -p $MPC/build cd $MPC/build echo "configure mpc ..."; ../configure --prefix=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX --build=x86_64-apple-darwin11 echo "building mpc ..."; make && make install fi rm -fr $GCC_SRC/build mkdir -p $GCC_SRC/build cd $GCC_SRC/build ../configure --prefix=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX --with-mpc=$PREFIX --enable-checking=release --program-suffix=-4.6.3 --enable-languages=c,c++,objc,obj-c++ make -j 4 && make install


(3) Test it
test_lambda.cpp    Select all
//Program to test the new C++11 lambda syntax #include <iostream> using namespace std; int main() { cout << [](int m, int n) { return m + n; } (2, 4) << endl; return(0); }


~/local/bin/g++-4.6.3 -std=c++0x test_lambda.cpp -o test_lambda
./test_lambda


Tuesday, June 19, 2012

androideabi Utilities Binaries

These are the utilities for Android Terminal Access

Download here
http://apiexplorer.googlecode.com/files/androideabi_binary.zip

bash 4.1 (requires root)
make (useful for  GCC Plugin for C4droid)
python (standalone script requires PythonForAndroid_r4.apk)
perl (standalone script requires perl_for_android_r1.apk)
vim (with multibyte support)
wget (in case your busybox's wget was broken with bad address)
curl (how I build this ? -> here)
utelnetd (telnet daemon,  utelnetd -p 1025 -l /system/bin/bash &)
scp
ssh
rsync

Instructions:
root the device and push these utilities to /system/bin/ or /system/xbin and chmod 04755 or chmod 755, if your /system folder is readonly, you might need Root Explorer to mount it as RW.

adb push bash /system/bin/bash
adb shell "chmod 04755 /system/bin/bash"

su -c /system/bin/bash


vim with multibyte support
Before the use of vim, you should setup TERM as
export TERM=xterm

And for editing UTF-8 File, use
vim --cmd "set encoding=utf-8" myfile.txt