• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeAndroidCompile and run C / C + + programC under Android d ...
Previous Next

Compile and run C / C + + programC under Android directly

Posted by: Alvin Jin , March 15, 2014

[vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Download” tab_id=”1394874986-1-6″][vc_column_text]Download gcc and pcDuino lib of Android version 

https://github.com/liaods/pcduino-gcc-on-android[/vc_column_text][/vc_tab][vc_tab title=”Unzip” tab_id=”1394874986-2-25″][vc_column_text]Unzip to android /data

Open Terminal APK, input

$ su
# busybox tar zxvf pcduino-android-gcc-20131218.tgz -C /data/
# busybox tar zxvf pcduino-android-arduino-20131218.tgz -C /data/

[/vc_column_text][/vc_tab][vc_tab title=”Write code” tab_id=”1394877067129-2-0″][vc_column_text]Write code and save, you can use busybox vi command or other graphical tools, or write on PC and copy to pcDuino.

For example:

/data/blink_led.c
#include <Arduino.h>
int led_pin = 18; // pcduino TX LED

void setup()
{
pinMode(led_pin, OUTPUT);
}

void loop()
{
digitalWrite(led_pin, HIGH);
delay(1000);
digitalWrite(led_pin, LOW);
delay(1000);
}[/vc_column_text][/vc_tab][vc_tab title=”Compile and run your program” tab_id=”1394877438561-3-5″][vc_column_text]Before first compile, run env.sh to setting environment

# . /data/pcduino-android-gcc/env.sh

Compile

# pcduino-cc blink_lec.c
target is blink_led

Run

#./blink_led

If you want to stop the program, push Ctrl + C.[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]

Tags: Android

Share!
Tweet

Alvin Jin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors