当前位置: 技术问答>linux和unix
编译的问题
来源: 互联网 发布时间:2015-08-27
本文导语: 有两个文件 main.c 和 func.c main.c中包含了 func.h文件 func.c单独编译成了func.o文件 我现在想编译main.c,应该如何引用func.o文件,我是这样写的: gcc main.c -o main -I./ -L./ 这样为什么不对,正确的应该怎么写? ...
有两个文件 main.c 和 func.c
main.c中包含了 func.h文件
func.c单独编译成了func.o文件
我现在想编译main.c,应该如何引用func.o文件,我是这样写的:
gcc main.c -o main -I./ -L./
这样为什么不对,正确的应该怎么写?
main.c中包含了 func.h文件
func.c单独编译成了func.o文件
我现在想编译main.c,应该如何引用func.o文件,我是这样写的:
gcc main.c -o main -I./ -L./
这样为什么不对,正确的应该怎么写?
|
first u should complie the fuc.o to a static or dynamic libray,static library for the command
ar qv libexp.a fuc.o
then u can compile the main.c with the command.
gcc -o main main.c -L ./ -lexp
then u will get it,u will payattention to the libexp.a and -lexp
ar qv libexp.a fuc.o
then u can compile the main.c with the command.
gcc -o main main.c -L ./ -lexp
then u will get it,u will payattention to the libexp.a and -lexp
|
gcc main.c func.o -o main
|
>gcc main.c func.o -o main
|
gcc main.c -o main -I头文件目录路径 -Llib库路径