LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 758|回复: 4

求助关于makefile文件的简单问题

[复制链接]
发表于 2005-3-13 11:39:37 | 显示全部楼层 |阅读模式
比如我的源程序为main.c,还包含其它头文件,我的makefile文件写好后,
现在这个文件怎么命名,然后在终端里用什么命令执行?问题很弱智,
请大侠不要见笑,说详细点 :thank
发表于 2005-3-13 12:23:19 | 显示全部楼层
这个文件指什么哪个文件?是不是编译后的可执行文件?贴一下你的makefile吧
回复 支持 反对

使用道具 举报

发表于 2005-3-13 13:01:34 | 显示全部楼层
makefile文件的名称可取Makefile
然后在终端下直接敲make就可以了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-13 13:36:39 | 显示全部楼层
Post by Linux_Lyb
这个文件指什么哪个文件?是不是编译后的可执行文件?贴一下你的makefile吧

我按照网上的一篇文章:
/* main.c */
  #include "mytool1.h"
  #include "mytool2.h"

  int main(int argc,char **argv)
  {
  mytool1_print("hello");
  mytool2_print("hello");
  }

  /* mytool1.h */
  #ifndef _MYTOOL_1_H
  #define _MYTOOL_1_H

  void mytool1_print(char *print_str);

  #endif

  /* mytool1.c */
  #include "mytool1.h"
  void mytool1_print(char *print_str)
  {
  printf("This is mytool1 print %sn",print_str);
  }

  /* mytool2.h */
  #ifndef _MYTOOL_2_H
  #define _MYTOOL_2_H

  void mytool2_print(char *print_str);

  #endif

  /* mytool2.c */
  #include "mytool2.h"
  void mytool2_print(char *print_str)
  {
  printf("This is mytool2 print %sn",print_str);
  }
# 这是上面那个程序的Makefile文件
  

  main:main.o mytool1.o mytool2.o
  gcc -o main main.o mytool1.o mytool2.o
  main.o:main.c mytool1.h mytool2.h
  gcc -c main.c
  mytool1.o:mytool1.c mytool1.h
  gcc -c mytool1.c
  mytool2.o:mytool2.c mytool2.h
  gcc -c mytool2.c
我的问题就是这个makefile文件怎么命名,后缀名是什么?保存后如何运行?

  
回复 支持 反对

使用道具 举报

发表于 2005-3-13 16:53:58 | 显示全部楼层
上面答拉
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表