Arria 10 SoC Virtual Platform User Guide

ID 683326
Date 9/16/2015
Public
Document Table of Contents

1.6.3. Creating and Cross-Compiling an Application on Host

  1. Go to your home folder on the host and create a file named factorial.c that contains the following source code:
    #include <stdio.h>
    
    int factorial(int n) {
          if (n == 0)         
                return 1;
          return n * factorial (n - 1);
    }
    
    int main () {
          int i;
          int n;
          for (i = 0; i < 10; ++i) {          
            n = factorial (i);           
            printf ("factorial(%d) = %d\n", i, n);
          }
          return 0;
    }
  2. Cross-compile the factorial.c file by typing the following command:
    arm-linux-gnueabihf-gcc factorial.c -ggdb -o factorial.out