当前位置: 技术问答>linux和unix
unix 环境下编程如何进行连接?(C语言)
来源: 互联网 发布时间:2015-02-11
本文导语: unix 环境下编程如何进行连接?(C语言) | cc -o exe a.c b.c or cc -c a.o b.o a.c b.c cc -o exe a.o b.o | cc to compile c source file CC to compile C++ source file -c option means u want t...
unix 环境下编程如何进行连接?(C语言)
|
cc -o exe a.c b.c
or
cc -c a.o b.o a.c b.c
cc -o exe a.o b.o
or
cc -c a.o b.o a.c b.c
cc -o exe a.o b.o
|
cc to compile c source file
CC to compile C++ source file
-c option means u want to compile source to an obj file
eg.
cc a.c -c
u will get an obj a.o
-o option means u want to link a binary file
eg.
cc a.c -o a
cc a.o -o a
the better way is use makefile
#makefile
#!/bin/bash
CC=g++
all:program
program:program.o bill.o
$(CC) $^ -o $@ -O -Wall
%.o:%.c
$(CC) -c $
CC to compile C++ source file
-c option means u want to compile source to an obj file
eg.
cc a.c -c
u will get an obj a.o
-o option means u want to link a binary file
eg.
cc a.c -o a
cc a.o -o a
the better way is use makefile
#makefile
#!/bin/bash
CC=g++
all:program
program:program.o bill.o
$(CC) $^ -o $@ -O -Wall
%.o:%.c
$(CC) -c $