香蕉派上的helloworld(hello.exe) - 炫Q香蕉派

香蕉派上的helloworld(hello.exe)

输入代码hello.c

#include <stdio.h>
int main()
{
  printf("Hello MikuQ.com!\n");
  return 0;
}

编译运行

gcc -Wall -o hello.exe hello.c
./hello.exe

效果如下
58.png

下面继续头文件MikuPi.h

#ifndef _MIKUPI_H_
#define _MIKUPI_H_

void sayhello();

#endif

库文件MikuPi.c

#include <stdio.h>
#include "MikuPi.h"

void sayhello()
{
  printf("Hello MikuQ.com!\n");
}

主文件hello2.c

#include "MikuPi.h"

int main()
{
  sayhello();
  return 0;
}

编译运行

gcc -Wall -o hello2.exe hello2.c MikuPi.c
./hello2.exe

继续

sudo mv MikuPi.h /usr/include/
gcc MikuPi.c -fPIC -shared -o libMikuPi.so
sudo mv libMikuPi.so /usr/lib/
gcc -Wall -o hello2.exe hello2.c -lMikuPi
./hello2.exe

再继续

sudo mv MikuDuino.h /usr/include/
gcc MikuDuino.c -fPIC -shared -o libMikuDuino.so
sudo mv libMikuDuino.so /usr/lib/
gcc -Wall -o hello3.exe hello3.c -lMikuDuino
./hello3.exe

hello3.c

#include "MikuDuino.h"

int i=0;

void setup()
{
  sayhello();
}

void loop()
{
  delay(5000);
  printf("%d\n",++i);
}

参考资料:
http://www.cnblogs.com/dyllove98/archive/2013/06/25/3155599.html

标签: none

添加新评论