linux下编译:单文件,多文件

来源:互联网 发布:淘宝哪里申请信用卡 编辑:程序博客网 时间:2024/05/10 17:24

gcc -c hello.c 只编译不链接 执行该语句之后生成hello.o文件

gcc -o hello hello.c 直接生成可执行文件hello

gcc -o hello hello.o 生成可执行文件hello

假如现在有两个文件 main.c print.c

print.c的内容

#include<stdio.h>

void print()

{

     printf("hello");

}

main.c的内容

#include<stdio.h>

void print();

int main()

{

print();

return 0;

}

执行命令:gcc -o print hello.c main.c

可生成可执行文件 print

0 0
原创粉丝点击