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

cxh1123 2013-05-07 09:57:40
在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文件要怎么一起编译
...全文
371 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
在制定源文件的时候明确路径就好了。
ouyh12345 2013-05-07
  • 打赏
  • 举报
回复
gcc -I./gcctest -o main main.c ./gcctest/test.c
buyong 2013-05-07
  • 打赏
  • 举报
回复
if you have so many this file, you could try CMake

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧