c++ - 如何修复“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
因此,如果你们中的任何人都知道如何在不更改目录结构的情况下包含我丢失的输入文件,那就太好了。
解决方案
推荐阅读
- flutter - 如何在颤动中从其 onTap() 函数更改列表图块的属性?
- python - Spyder 中的 Pylint 在 conda 环境中引发“E401 无法导入”
- javascript - 导航到下一页时如何正确清理打开的菜单
- r - 来自 R 中 QAP Logistic 回归的伪 R^2 度量(sna 包中的 netlogit)
- firebase - 使用模拟器而不是云进行 Firebase 云功能测试
- mongodb - 如何为嵌套文档编写聚合查询?
- ios - 在代码中使用 Info.plist 中定义的键作为常量
- keycloak - 在 keycloak 中组织和验证公司
- python-3.x - MemoryError:无法为形状(725000、277、76)和数据类型 float64 的数组分配 30.4 GiB
- c# - BackgroundService.StartAsync,它应该在启动期间完成还是阻塞?