How do I setup the Core or PI and COMPILE in C?

How do I setup the Board so that I can Compile C Programs ?

  • Is there a CC / GCC Compiler on the Board ?
  • Do I need to Install CC / GCC ?
  • Do I need to use a Flash Drive ?
    I can not find a Compiler on the installed Linux.

I don’t think there is a compiler on the board. You have to use cross compiler on your PC.

http://wiki.openwrt.org/about/toolchain
http://wiki.openwrt.org/doc/devel/crosscompile

You can use OpenWrt or Mips tool chain.

If there is a GCC compiler for Linux,
we should be able to install it on the SD Card /mnt/sda/,
to allow us to compile locally on the chip.

But, I need the Compiler package.

There are ways to compile C/C++ on the Arduino Yun, I suppose they should work on the Domino as well. Here are some references: http://noblepepper.com/wp/blog/2014/10/22/gcc-g-on-an-arduino-yun/, http://forum.arduino.cc/index.php?topic=241368.0, http://arduino.stackexchange.com/questions/3055/arduino-yun-c-environment-bridge-cross-compiler. Depending on the size of the projects you want to build, a cross-compiler on a beefier machine may be the better option though.

I have not tried either (but plan to, at some point).

Actually,
I had a simpler goal in mind.

I only wish to compile code to create new Commands and Programs for the Domino,

  • say to run Commands from the Command Line,
  • or maybe a MENU to call Commands via external Buttons on the Domino,
  • or just Commands to execute from Startup Scripts.

I think many users on the Domino might prefer this to Recompiling the entire Root Image.

You don’t need to recompile the entire image, but as far as I gather, starting to recompile the entire image is the easiest way of obtaining a cross-compiler. You can stop after that.

Just now, I downloaded YunGcc.tgz from a site:


    Sniff: Building GCC for the Yun (in 12 not-easy steps)
    http://www.sniff.org.uk/2014/05/building-gcc-for-yun-in-12-not-easy.html

I dropped on the SDcard, and it seems to run.


root@domino:/mnt/sda1/Code# PATH=$PATH:/mnt/sda1/gcc/bin/
root@domino:/mnt/sda1/Code# ../gcc/bin/c++ test.g++
  ld: applet not found
  collect2: ld returned 1 exit status

.
But no gcc.

Its missing files gcc and g++ and ld .
(Because they are just links):


root@domino:/mnt/sda1/Code# ls -l ../gcc/bin/

-rwxrwxrwx    1 root     root       4076623 May 16  2014 addr2line
-rwxrwxrwx    1 root     root       4212791 May 16  2014 ar
-rwxrwxrwx    1 root     root       5970377 May 16  2014 as
-rwxrwxrwx    1 root     root        860045 May 16  2014 c++
-rwxrwxrwx    1 root     root       4030272 May 16  2014 c++filt
-rwxrwxrwx    1 root     root        854402 May 16  2014 cpp
-rwxrwxrwx    1 root     root        202802 May 16  2014 elfedit
-rwxrwxrwx    1 root     root             0 May 16  2014 g++
-rwxrwxrwx    1 root     root             0 May 16  2014 gcc
-rwxrwxrwx    1 root     root        190086 May 16  2014 gcov
-rwxrwxrwx    1 root     root       4561528 May 16  2014 gprof
-rwxrwxrwx    1 root     root             0 May 16  2014 ld
-rwxrwxrwx    1 root     root       6244088 May 16  2014 ld.bfd
-rwxrwxrwx    1 root     root             0 May 16  2014 mips-openwrt-linux-uclibc-c++
-rwxrwxrwx    1 root     root             0 May 16  2014 mips-openwrt-linux-uclibc-g++
-rwxrwxrwx    1 root     root             0 May 16  2014 mips-openwrt-linux-uclibc-gcc
-rwxrwxrwx    1 root     root        853203 May 16  2014 mips-openwrt-linux-uclibc-gcc-4.6.4
-rwxrwxrwx    1 root     root       4100925 May 16  2014 nm
-rwxrwxrwx    1 root     root       4723634 May 16  2014 objcopy
-rwxrwxrwx    1 root     root       5364989 May 16  2014 objdump
-rwxrwxrwx    1 root     root       4212806 May 16  2014 ranlib
-rwxrwxrwx    1 root     root       1073138 May 16  2014 readelf
-rwxrwxrwx    1 root     root       4094673 May 16  2014 size
-rwxrwxrwx    1 root     root       4063411 May 16  2014 strings
-rwxrwxrwx    1 root     root       4723645 May 16  2014 strip

Okay, they are Links, but do not appear on FAT32.
So, I just copied the files :


root@domino:/mnt/sda1/gcc/bin# cp ld.bfd ld

root@domino:/mnt/sda1/gcc/bin# cp c++ g++

root@domino:/mnt/sda1/gcc/bin# cp mips-openwrt-linux-uclibc-gcc-4.6.4 gcc

root@domino:/mnt/sda1/gcc/bin# cp mips-openwrt-linux-uclibc-gcc-4.6.4 mips-openwrt-linux-uclibc-gcc

root@domino:/mnt/sda1/gcc/bin# cp c++ mips-openwrt-linux-uclibc-c++

root@domino:/mnt/sda1/gcc/bin# cp c++ mips-openwrt-linux-uclibc-g++

And now try to Compile:


root@domino:/mnt/sda1/gcc/bin# cd ../../Code/

root@domino:/mnt/sda1/Code# ls
  initGcc   test.c    test.c++  test.g++

root@domino:/mnt/sda1/Code# ../gcc/bin/gcc test.c
  /mnt/sda1/gcc/bin/ld:/mnt/sda1/gcc/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.4/crtbegin.o:  file format not recognized; treating as linker script
  /mnt/sda1/gcc/bin/ld:/mnt/sda1/gcc/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.4/crtbegin.o:1: syntax error
  collect2: ld returned 1 exit status

.
I need to partiton and Format the SD Card in Linux.
I dont have a Linux available to me at the moment - just Cygwin.
Any suggestions ?

In openwrt you can actually partition and format a disk directly. Please check here:

http://wiki.openwrt.org/doc/howto/storage

Task Complete !

I downloaded YunGcc.tgz and UnTARred it onto my SDCard,
then compiled using GCC fom SD Card :


// testSpd.c : //
// - loop=400,000,000 => IPS = ((400000000 * 5) / 10 seconds) = 200 MIPS

#include <stdio.h>

void main()
{
long  i;

  printf("Start ..\n");

  for(i=0;i<400000000;i++)
  {
  }

  printf("Done !\n");
}

root@domino:/mnt/sda2/Code# gcc testSpd.c
  /mnt/sda2/gcc/bin/ld: Warning: a.out uses -msoft-float (set by /mnt/sda2/gcc/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.4/crtbegin.o), /tmp/cc80ZcyD.o uses -mhard-float

root@domino:/mnt/sda2/Code# ./a.out
  Start ..
  Done !

root@domino:/mnt/sda2/Code#