c++ - Makefile 问题 : g++: fatal error: no input files

标签 c++ makefile file-not-found

我已经做过的事情:

我查看了其他具有类似问题的 StackOverflow 线程,但它们似乎都不适用于我的具体情况。我还仔细检查以确保正确的文件位于正确的位置(文件夹)并且所有内容的命名也正确。

这是我收到的错误:

[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

这是有问题的 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 collar.h
    $(CC) $(CFLAGS) -o collar.cpp

clean:
    -rm -f ${TARGETS}

这里是 makefile 引用的文件(它们都在同一个目录中):

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

我做错了什么?

最佳答案

尝试做

   $(CC) $(CFLAGS) - c collar.cpp -o compiledfilename

Compiledfilename 是二进制文件的名称。

关于c++ - Makefile 问题 : g++: fatal error: no input files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21653680/

相关文章:

c++ - 为什么在 C++ 中不允许连接两个 const char*?

c++ - 如何使用 SDL2 Texture 作为更新 Canvas ?

c++ - 嵌套 c++11 范围循环以查找组合

makefile - 如何通过测试文件是否存在来有条件地设置 Makefile 变量

c++ - Visual Studio 2013 (vs120) 要求错误的 boost 库

c++ - Codelite 调试器错误 : Failed to locate gdb! 在 '/usr/bin/gdb'

linux - 如何在 Makefile 中找到基础架构?

linux - 不能在内核模块 makefile 中使用通配符

java - 将 java 项目导出为 JAR 并尝试在 ECLIPSE 的动态 Web 项目中使用它后,找不到资源文件

iPhone - ShareKit 、 SHKm 给出“找不到文件”的编译器错误