免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1433 | 回复: 5
打印 上一主题 下一主题

救急啊! 请教一个Makefile问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-11-18 03:39 |只看该作者 |倒序浏览
我有个多文件程序 main.cpp  coalescent.cpp  transition.cpp  math_functions.cpp  test.cpp ,    parameters.h   node.h   random.h
写了一个Makefile, 但运行的时候总是出错, 我刚开始学makefile, 求救于各位了!!!

# ----------------------------------------------- #
# This is the Makefile for Xi coalescent program. #
# ----------------------------------------------- #

program: main.o test.o coalescent.o transition.o math_functions.o
        g++ -o program main.o test.o coalescent.o transition.o math_functions.o
main.o: main.cpp parameters.h node.h
        g++ -c main.cpp
test.o: test.cpp parameters.h node.h
        g++ -c test.cpp
coalescent.o: coalescent.cpp parameters.h node.h
        g++ -c coalescent.cpp
transition.o: transition.cpp parameters.h
        g++ -c transition.cpp
math_functions.o: math_functions.cpp random.h
        g++ -c math_functions.cpp

# End of Makefile


出错信息是:
make: Fatal error in reader: Makefile, line 5: Unexpected end of line seen

论坛徽章:
0
2 [报告]
发表于 2004-11-18 03:59 |只看该作者

救急啊! 请教一个Makefile问题

帮你改了一下,应该可以了(在cygwin下测试通过)

  1. # ----------------------------------------------- #
  2. # This is the Makefile for Xi coalescent program. #
  3. # ----------------------------------------------- #

  4. program: main.o test.o coalescent.o transition.o math_functions.o
  5.         g++ -o program main.o test.o coalescent.o transition.o math_functions.o
  6. main.o: main.cpp parameters.h node.h
  7.         g++ -c main.cpp
  8. test.o: test.cpp parameters.h node.h
  9.         g++ -c test.cpp
  10. coalescent.o: coalescent.cpp parameters.h node.h
  11.         g++ -c coalescent.cpp
  12. transition.o: transition.cpp parameters.h
  13.         g++ -c transition.cpp
  14. math_functions.o: math_functions.cpp random.h
  15.         g++ -c math_functions.cpp

  16. # End of Makefile
复制代码

注意:命令前面不是空格,是Tab符!

论坛徽章:
0
3 [报告]
发表于 2004-11-18 05:53 |只看该作者

救急啊! 请教一个Makefile问题

这个我知道
是不是在
program: main.o test.o coalescent.o transition.o math_functions.o
换行"回车"
然后用一次"Tab"符 再接  g++ -o program main.o test.o coalescent.o transition.o math_functions.o

下面都一样, 是这样把. 但我就这样写的不对啊,
copy了上面的代码,还不是不能运行, copy 下来的代码还是用空格的

论坛徽章:
0
4 [报告]
发表于 2004-11-18 10:16 |只看该作者

救急啊! 请教一个Makefile问题

是不是windows跟unix下文件格式不一样的问题啊?用vi看看。

论坛徽章:
0
5 [报告]
发表于 2004-11-18 11:48 |只看该作者

救急啊! 请教一个Makefile问题

可能是文件格式的原因吧,楼上说的对用vi看看,我以前也遇到过类似的问题的,搞了半天是win下面和unix下的换行符不一样

论坛徽章:
0
6 [报告]
发表于 2004-11-18 14:03 |只看该作者

救急啊! 请教一个Makefile问题

你不能copy的,因为网页做了转换。
你要自己写上才对。现今的Linux下的make工具已经能自动处理回车符的问题了的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP