之前我们用了Jetbrain更现代的IDE进行了Hello World,总感觉少了点什么,这次我们用最原始的命令行重新来一次hello world
$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.29)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
创建一个源码文件
$ vim helloc.c
#include<stdio.h>
int main() {
printf("Hello world!\n");
return 0;
}
使用gcc进行编译
$ gcc helloc.c
就会生成可执行文件了
$ ls -l
drwxr-xr-x 6 junjiexun staff 192B 4 16 22:49 a.out*
-rw-r--r-- 1 junjiexun staff 83B 4 16 22:56 helloc.c
直接运行就行
$ ./a.out
Hello world!
网友评论