【问题标题】:Make: *** [] Error 1Make: *** [] 错误 1
【发布时间】:2013-04-09 06:22:06
【问题描述】:

我制作了一个 makefile 并尝试对其进行测试,但在 make 中出现错误:

austins-macbook:work4 staffmember$ make new
rm -f main.o heap.o heap
gcc -Wall -O2   -c -o main.o main.c
gcc -Wall -O2   -c -o heap.o heap.c
heap.c: In function ‘createHeap’:
heap.c:6: warning: implicit declaration of function ‘malloc’
heap.c:6: warning: incompatible implicit declaration of built-in function ‘malloc’
heap.c:8: warning: implicit declaration of function ‘exit’
heap.c:8: warning: incompatible implicit declaration of built-in function ‘exit’
gcc -Wall -O2 -o heap main.o heap.o
austins-macbook:work4 staffmember$ make test
./heap
make: *** [test] Error 1

我认为得到 make * 错误 1 ​​意味着您的组件之一没有正确编译,但是当我编译它时没有任何错误消息。如何找出问题所在?

【问题讨论】:

  • 虽然这与您的问题无关,但您可能希望将缺少的 #includes 添加到 heap.c

标签: c gcc makefile


【解决方案1】:

./heap 可能返回了一个非零退出代码,make 将其解释为错误。确保您在 main 末尾执行 return 0;

【讨论】:

  • 这是正确的,我没有在 main 末尾返回 0。谢谢!
猜你喜欢
  • 2019-03-27
  • 1970-01-01
  • 1970-01-01
  • 2011-07-28
  • 2014-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多