All these instructions are to be run on the Beaglebone itself using putty.
Install the C Compiler, make and a few other bits and pieces with
opkg install task-native-sdk
Make a folder for your code by running
mkdir code
cd code
Now create a makefile using nano
nano Makefile
Paste the following code and then press ctrl+O and then ctrl+x
CC = gcc
CFLAGS = -Wall -g -O2
OBJECTS = main.o
all: $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) -o main
Now create the C source file by running
nano main.c
Paste the following code and then press ctrl+O and then ctrl+x
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main (int argc, char **argv)
{
printf (“Hello from BeagleBone”);
return 0;
}
To compile your new application run
make all
To run your application
./main
make all
Makefile:7: *** missing separator. Stop.
I am getting the above error
LikeLike
You need tabs to indent the lines underneath each target.
CC = gcc
CFLAGS = -Wall -g -O2
OBJECTS = main.o
all: $(OBJECTS)
$(CC) $(CFLAGS) $(OBJECTS) -o main
LikeLike
I’m sorry, but where do you want us to indent it? I’m a little confused.
LikeLike
Thanks for this. I just got my BeagleBone out of the box for the first time, and was getting sick of the official docs. I wanted to get to coding ASAP and finding your Hello World example was the gateway I wanted.
LikeLike