如何用makefile编译多个目录之间的.h .c文件呢

MichaelBomb MichaelBomb 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的linux下,有这几个目录:
~/tmp/test/learn/ 目录下文件:main.c。 里面主函数调用helloworld.c的helloworld函数,以及test.c下的test函数。
main.c代码:

#include <stdio.h>
#include "helloworld.h"
#include "test.h"
int main()
{
test();
helloworld();
return 0;
}

~/tmp/test/learn/math/ 目录下文件: test.h test.c 。里面函数都是简单输出一句话
~/tmp/test/ 目录下文件: helloworld.h helloworld.c。 简单输出一句话

然后我在main.c所在的目录下,即~/tmp/test/learn/ 建立了一个Makefile文件。
像这样主函数调用的函数在不同目录下的头文件中,这样的Makefile该如何写呢?
我试着写了一个 一直提示 test.h 不存在:test.h: No such file or directory.

大虾们,可否写个makefile瞧瞧,应该比较简单吧~,并解释下原因?十分感谢。
...全文

相关推荐

评论 10
收藏 已收藏
分享
返回顶部
MichaelBomb
Linux/Unix社区 23,224 成员 74,535 内容