读书人

gcc编译多个不同行径下的.c文件

发布时间: 2013-06-26 14:29:32 作者: rapoo

gcc编译多个不同路径下的.c文件
在home/hcx/gcc下,一个main.c,代码如下

#include <stdio.h>
#include "test.h"

int main()
{
print();
return 0;
}
,在home/hcx/gcc/gcctest下,一个test.c
#include <stdio.h>
#include "test.h"

void print()
{
printf("this is print func\n");
}
和一个test.h
#ifndef _TEST_H_
#define _TEST_H_

void print();

#endif
这样gcc要怎么写?也就是不同路径下的.c文件要怎么一起编译 gcc
[解决办法]
gcc -I./gcctest -o main main.c ./gcctest/test.c

读书人网 >C++

热点推荐