美文网首页android framework
android framework 升级第3天

android framework 升级第3天

作者: Blanchard | 来源:发表于2021-01-24 07:51 被阅读0次

C 语言基础

Hello_World_Brian_Kernighan_1978.jpg

直接开始

  • 找一台 linux 系统或者虚拟机,
  • 打开终端窗口
  • 直接运行下面脚本,或者手工每一行敲进终端窗口
mkdir -p ~/src/hello_c
cat>~/src/hello_c/hello.c<<EOF
#include <stdio.h>          /* header provide printf */
int main (int argc, char *argv[]) /* main entry function */
{
    printf("Hello World\n");/* to output the string on a display */
    return 0;
}
EOF
gcc -o hello.bin hello.c
./hello.bin

Makefile 版本

cat>>~/src/hello_c/Makefile<<EOF
# This is the default target, which will be built when 
# you invoke make
.PHONY: all
all: hello install

# This rule tells make how to build hello from hello.c
hello: hello.c
    gcc -o hello.bin hello.c

# This rule tells make to copy hello to the binaries subdirectory,
# creating it if necessary
.PHONY: install
install:
    mkdir -pv ~/bin
    cp -pv hello.bin ~/bin
    ~/bin/hello.bin

# This rule tells make to delete hello and hello.o
.PHONY: clean 
clean:
    rm -vf hello.bin
    rm -vf ~/bin/hello.bin
EOF
sed -i 's/    /\t/g' ~/src/hello_c/Makefile
make -C ~/src/hello_c 

参考

https://www.oreilly.com/library/view/c-cookbook/0596007612/ch01s16.html
https://en.wikipedia.org/wiki/%22Hello,_World!%22_program

相关文章

网友评论

    本文标题:android framework 升级第3天

    本文链接:https://www.haomeiwen.com/subject/pgwpzktx.html