Makefile:没有这样的文件或目录
Makefile: No such file or directory
目录结构如下:
- src
- /GUILayer
- /PhysicLayer
- /LogicLayer
- /Utilities
- main.cpp
- makefile
- makefile.inc
这是src
中当前的makefile
include makefile.inc
DIRS = PhysicLayer LogicLayer GUILayer Utilities
OBJLIBS = PhysicLayer.a LogicLayer.a GUILayer.a Utilities.a
EXTERNOBJ = $(foreach path, $(DIRS), $(wildcard $(path)/*.o))
TARGETS = main.cpp
EXE = main
all : $(EXE)
%.a :
-for d in $(DIRS); do (cd $$d; $(MAKE)); done
ar cr $@ $^
main: $(OBJLIBS)
$(ECHO) $(CC) $(CFLAGS) $(EXTERNOBJ) $(OBJLIBS) -o $@ $(TARGETS)
$(CC) $(CFLAGS) $(EXTERNOBJ) $(OBJLIBS) -o $@ $(TARGETS)
clean :
-$(RM) -f ./main
find . -name "*.o" -type f -print | xargs /bin/rm -f
find . -name "*.a" -type f -print | xargs /bin/rm -f
文件夹内的文件生成。o很好,但main
根本不生成。下面是终端的输出:
g++ -Wall -pedantic -pedantic-errors -g -ggdb PhysicLayer.a LogicLayer.a GUILayer.a Utilities.a -o main main.cpp
/tmp/ccA3VJed.o: In function `main':
/home/user/Desktop/project/src/main.cpp:14: undefined reference to `Indexador::Indexador()'
/home/user/Desktop/project/src/main.cpp:19: undefined reference to `Indexador::indexar(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/home/user/Desktop/project/src/main.cpp:38: undefined reference to `Indexador::~Indexador()'
/home/user/Desktop/project/src/main.cpp:38: undefined reference to `Indexador::~Indexador()'
collect2: ld returned 1 exit status
make: *** [main] Error 1
在您的规则$(CC) $(CFLAGS) $(EXTERNOBJ) -c $@ $(TARGETS)
中,您应该将-c
更改为-o
,否则g++
将假设$@
是一个输入文件并查找尚未存在的main
。
相关文章:
- 使用 Makefile 中的头文件编译 Pybind (不使用 cmake)
- Arduino-Makefile:编译器无法编译用户库 cpp 文件
- C++ 如何将两个 makefile 对象目标规则(位于另一个文件夹中)合并到一个目标/规则中?
- 如何在makefile中包含tensorflow c ++".so"文件?
- 有没有办法从Makefile访问VS Code c_cpp_properties.json文件中的定义
- 在Windows上运行Linux Makefile(.so文件)
- 为简单的src,include,libs文件夹项目编写Makefile
- 如何从 Makefile 中的其他目录导入所有源代码和头文件
- 使用 g++ 和 Makefile 编译 c++ 时可执行文件非常大
- Makefile在Linux中工作,但在Windows下不起作用,在子目录中找不到文件
- makefile和错误将与大型项目分开的文件编译
- 当自动编译对象文件时,如何使我的makefile使用我的cflags标志
- makefile 没有将 .o 和可执行文件放在各自的 obj 和 bin 目录中
- 如何仅重新编译makefile中更改的内容,自动查找.cpp文件?
- Arduino Makefile:如何将传感器数据保存到计算机中的文件中
- 使用GCC的C makefile - 从子文件夹列表中生成源文件列表
- 自动工具: Makefile.am:如果文件存在,则链接
- 您可以使用 makefile 从 .o 对象文件创建 C++ 文件吗?
- 多个文件Makefile编译
- 一个文件Makefile问题:C++