首页 > 解决方案 > 如何修复“g++:致命错误:没有输入文件编译终止。” 错误

问题描述

我的第一个更大的 makefile 项目遇到了一些麻烦。我在我的 c++ 项目中使用了一个更大的库。更准确:在我的 .cpp 文件和 .h 文件中,我需要从这个更大的库中包含一些头文件。

这是我的结构,让你知道我是如何在我的项目中使用这个库的:

myproj
  |
  |____Makefile
  |____main.cpp
  |____init.cpp
  |____end.cpp
  |____init.h
  |____end.h
  |____Dependencies
           |____biggerlib
                   |____bin   
                           |____...
                   |____include
                           |____#more directories including
                                #the Library headers
                           |____...
                   |____src
                           |____biggerLib1
                           |____biggerLib2
                                   |____biggerLibrary.cpp
                                          |____...
                                   |____Lib2.cpp
                                          |____...
                                   |____Lib3.cpp
                                          |____...
                                   |____Util
                                          |____DebugOut.cpp
                                   |____Dev
                                   |____Data
                                          |____etc.
                   |____makestuff
                           |____...
                           |____...
                                   |____...
                           |____...
                   |____codestuff
                           |____...
                           |____...
                                   |____...
                           |____...
                   |____etc.

我不允许更改该结构。

所以,我的问题是,如果我开始 make,gcc 或 g++ 找不到我的输入文件。错误代码:

g++: fatal error: no input files
compilation terminated.
*makefileName*:21: recipe for target '*Name*' failed
make: *** [*Name*] Error 1

因此,这里有一些我的 makefile:起初我的 OBJECTS 文件:

OBJECTS += \
$(BUILD)main.o \
$(BUILD)init.o \
$(BUILD)end.o 

然后我的makefile:

#Name (output name / project name)
NAME = proj

#Compiler directory
CC = gcc
CPP = g++
#Libray directorys
SDCC = /home/myname/myproj/Dependencies/biggerlib/src/biggerLib2/Util

# the headers are working well since yesterday but now i got the trouble with the input stuff...

#C-Flags for object-compiling
CFLAGS = -O2 -g3 -c -I$(SDCHDR) -I$(SDCDATAMODEL) -I$(SDCPOCO) #may i have to add here the source files too? did not work...

#Main-target (linking)
$(NAME) : $(OBJECTS)
    $(CPP) -o $(NAME) -I$(SDCC)/DebugOut.cpp ## this one was just to try if I could bind in one single .h file... 

#Object-targets
%.o : %.cpp 
    $(CPP) -o $@ $< $(CFLAGS)

我的制作命令:

make -f makefilename

因此,如果你们中的任何人都知道如何在不更改目录结构的情况下包含我丢失的输入文件,那就太好了。

标签: c++cmakefilegnu-makedirectory-structure

解决方案


推荐阅读