User Tools

Site Tools


Sidebar

Launch of Linino.org

wiki:gcc-native

Build native C code on your board with the GNU gcc 4.6.3 for MIPS

Hello Linino people ! Finally we are able to provide a native GCC compiler for your Linino board. It is now possible to write and run your C code directly on your LininoOS. To install it and start programming, first you have to upgrade your board to the latest Linino image. Please carefully take a look how to do it here :

How to upgrade the Linino distribution

If you own a Arduino Yun (and your control panel is the jade green colored one) please stick with the master branch of Linino otherwise you may brick your board ! On the contrary, owners of a Linino ONE can also refer to the lininoIO branching if already on natively installed on their boards.

Since the gcc package is quite cumbersome (it's about 15MB in its compressed form), you have to expand you filesystem to install it properly. Currently, the easiest and fastest way is to use our node.js installation script which will take for you of all the necessary steps :

Node.js installation script

Once rebooted and logged in by means of SSH, type :

$ opkg update
$ opkg install gcc -d mnt

and the system will install the GCC compiler package on the expanded filesystem residing on your external flash memory (it will take a while since as I told before the package it's quite cumbersome !). Once the installation has finished run :

$ gcc -v

that should return :

root@onetest /root [#]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/usr/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3/lto-wrapper
Target: mips-openwrt-linux-uclibc
Configured with: /home/build/builddir/lininoIO/linino_distro/build_dir/target-mips_r2_uClibc-0.9.33.2/gcc-4.6.3/configure --target=mips-openwrt-linux --host=mips-openwrt-linux --build=x86_64-linux-gnu --program-prefix= --program-suffix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls --build=x86_64-linux-gnu --host=mips-openwrt-linux-uclibc --target=mips-openwrt-linux-uclibc --enable-languages=c,c++ --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='Linino GCC 4.6.3' --enable-shared --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-nls --disable-libmudflap --disable-multilib --disable-libgomp --disable-libquadmath --disable-libssp --disable-subdir-texinfo MAKEINFO=missing --disable-decimal-float --disable-libstdcxx-pch --with-host-libstdcxx=-lstdc++ --prefix=/usr --libexecdir=/usr/lib --with-float=soft
Thread model: posix
gcc version 4.6.3 (Linino GCC 4.6.3)

you're now ready to write and build your own code ! Let's write together the “Hello World” example. First create a file with the touch command :

$ touch hello.c

then open it with your favourite text editor and insert the C code :

/* hello.c */
#include <stdio.h>
 
int main() {
    printf ("Hello world!\n");
    return 0;
}

after saving it, build it with the compiler itself :

$ gcc hello.c  -o hello

After the compilation is finished, run it with just :

$ ./hello

the output should be :

Hello world!

if that works, you're ready to go ! Happy Coding from Linino !

/var/www/wiki.linino.org/data/pages/wiki/gcc-native.txt · Last modified: 2015/06/20 10:23 by arturo

2014 © dog hunter llc and the Linino Community. Linino.org is a dog hunter sponsored community project. Credits