Makefile问题:g ++:fatal错误:没有输入文件 [英] Makefile issues: g++: fatal error: no input files

查看:3637
本文介绍了Makefile问题:g ++:fatal错误:没有输入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了:



我已经浏览了其他类似问题的StackOverflow线程,适用于我的具体情况。我也双重检查,以确保正确的文件在正确的位置(文件夹),并且一切都命名正确。



这是错误我'm receiving:

  [employee_xyz@petco.com] $ make 
g ++ -Wall -O2 -ansi -pedantic -o dog.cpp
g ++:致命错误:没有输入文件
编译终止。
make:*** [mscp.o]错误4

这是makefile :

  CC = g ++ 
CFLAGS = -Wall -O2 -ansi -pedantic -Werror

TARGETS = dog dog.o collar.o

dog:dog.o collar.o
$(CC)$(CFLAGS)-o dog collar.o dog.o

dog.o:dog.cpp collar.h
$(CC)$(CFLAGS)-o dog.cpp

collar.o:collar.cpp领。 h
$(CC)$(CFLAGS)-o collar.cpp

clean:
-rm -f $ {TARGETS}

这些文件(它们都在同一目录中)被makefile引用:

  -collar.cpp 
-collar.h
-makefile
-dog.cpp



我做错了什么?

解决方案

  dog.o:dog.cpp collar.h 
$(CC)$(CFLAGS)-o dog.cpp

collar.o:collar.cpp collar.h
$(CC)$(CFLAGS)-o collar.cpp

应为

  dog.o:dog.cpp collar.h 
$(CC)$(CFLAGS)-c dog.cpp

collar.o:collar.cpp collar.h
$(CC)$(CFLAGS) -c collar.cpp


What I've already done:

I've looked through other StackOverflow threads with similar issues, but none of them seem to apply to my specific case. I've also double checked to makes sure that the correct files are in the correct locations (folders) and that everything is named properly as well.

This is the error I'm receiving:

[employee_xyz@petco.com]$ make
g++ -Wall -O2 -ansi -pedantic -o dog.cpp
g++: fatal error: no input files
compilation terminated.
make: *** [mscp.o] Error 4

Here's the makefile in question:

CC = g++
CFLAGS = -Wall -O2 -ansi -pedantic -Werror

TARGETS = dog dog.o collar.o

dog: dog.o collar.o
    $(CC) $(CFLAGS) -o dog collar.o dog.o

dog.o: dog.cpp collar.h
    $(CC) $(CFLAGS) -o dog.cpp

collar.o: collar.cpp collar.h
    $(CC) $(CFLAGS) -o collar.cpp

clean:
    -rm -f ${TARGETS}

Here are the files (they're all in the same directory) that are being referenced by the makefile:

-collar.cpp
-collar.h
-makefile
-dog.cpp

What am I doing wrong?

解决方案

This

dog.o: dog.cpp collar.h
    $(CC) $(CFLAGS) -o dog.cpp

collar.o: collar.cpp collar.h
   $(CC) $(CFLAGS) -o collar.cpp

should read

dog.o: dog.cpp collar.h
    $(CC) $(CFLAGS) -c dog.cpp

collar.o: collar.cpp collar.h
    $(CC) $(CFLAGS) -c collar.cpp

这篇关于Makefile问题:g ++:fatal错误:没有输入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆