.c单文件:
rani@DocR:~/Downloads$ mkdir test
rani@DocR:~/Downloads$ cd test
rani@DocR:~/Downloads/test$ vim hello.c
rani@DocR:~/Downloads/test$ gcc hello.c -o hello
rani@DocR:~/Downloads/test$ ./hello
Hello world
.cpp单文件
rani@DocR:~/Downloads/test$ vim print_int.cpp
rani@DocR:~/Downloads/test$ g++ print_int.cpp -o print_int
rani@DocR:~/Downloads/test$ ./print_int
a = 5
5
cpp文件使用g++编译,c文件使用gcc编译,除此之外没有不同
.cpp多文件(c文件类似)
rani@DocR:~/Downloads/test$ mkdir multi
rani@DocR:~/Downloads/test$ cd multi/
rani@DocR:~/Downloads/test/multi$ vim main.cpp
rani@DocR:~/Downloads/test/multi$ vim myprint.cpp
rani@DocR:~/Downloads/test/multi$ vim myprint.h
rani@DocR:~/Downloads/test/multi$ g++ main.cpp myprint.cpp myprint.h -o myprint
rani@DocR:~/Downloads/test/multi$ ./myprint
hello print
标签:文件,multi,DocR,Downloads,rani,编译,cpp,linux,test
From: https://www.cnblogs.com/Yami-Wa/p/18095940