当前位置: 技术问答>linux和unix
关于linux makefile 的编写,哪位高手帮我看看下面的问题
来源: 互联网 发布时间:2016-11-27
本文导语: 下面是我make之后的结果 [root@localhost fun]# make make: *** No rule to make target `mian.o', needed by `main'. Stop. [root@localhost fun]# ls fun.c fun.h main.c makefile [root@localhost fun]# 我还从网上搜索过类似的,但是他们是说ma...
下面是我make之后的结果
[root@localhost fun]# make
make: *** No rule to make target `mian.o', needed by `main'. Stop.
[root@localhost fun]# ls
fun.c fun.h main.c makefile
[root@localhost fun]#
我还从网上搜索过类似的,但是他们是说makefile文件中的main与c程序文件中的main的大小写不一致,
但是我这边大小写都是一样啊,我找不出错误来,哪位高手帮我改改,谢谢。
3个原文件为:(这3个文件是没有问题的)
1:main.c
#include "fun.h"
int main(void)
{
int a,b;
printf("Please enter the number a an bn");
scanf("%d%d",&a,&b);
int max=0;
max=max_fun(a,b);
printf("The max number is %dn",max);
return 0;
}
2:fun.c
#include "fun.h"
int max_fun(int x,int y)
{
if(x>=y)
return x;
else
return y;
}
3:fun.h
#include
extern int max_fun(int x,int y);
我的makefile是这样写的:(这是书上的例子,我认真对照过,跟书上的一摸样)
OBJS=mian.o fun.o
CC=gcc
CFLAGS=-c
main:$(OBJS)
$(CC) $^ -o $@
main.o:main.c fun.h
$(CC) $(CFLAGS) $
[root@localhost fun]# make
make: *** No rule to make target `mian.o', needed by `main'. Stop.
[root@localhost fun]# ls
fun.c fun.h main.c makefile
[root@localhost fun]#
我还从网上搜索过类似的,但是他们是说makefile文件中的main与c程序文件中的main的大小写不一致,
但是我这边大小写都是一样啊,我找不出错误来,哪位高手帮我改改,谢谢。
3个原文件为:(这3个文件是没有问题的)
1:main.c
#include "fun.h"
int main(void)
{
int a,b;
printf("Please enter the number a an bn");
scanf("%d%d",&a,&b);
int max=0;
max=max_fun(a,b);
printf("The max number is %dn",max);
return 0;
}
2:fun.c
#include "fun.h"
int max_fun(int x,int y)
{
if(x>=y)
return x;
else
return y;
}
3:fun.h
#include
extern int max_fun(int x,int y);
我的makefile是这样写的:(这是书上的例子,我认真对照过,跟书上的一摸样)
OBJS=mian.o fun.o
CC=gcc
CFLAGS=-c
main:$(OBJS)
$(CC) $^ -o $@
main.o:main.c fun.h
$(CC) $(CFLAGS) $
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
站内导航:
特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!