链接器命令 - 没有为第三方库设定目标的规则
Linker command - No rule to make target for 3rd party lib
在我的代码中,我像这样引用这个pugixml:
#include "pugi/pugixml.hpp"
编译时出现此错误:
main in main-bf0b72.o
"pugi::xml_node::children(char const*) const", referenced from:
_main in main-bf0b72.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [main] Error 1
从另一个问题中,我被告知将 pugi 作为一个额外的翻译单元,并在我的 Makefile 中相应地链接它们:
CC = g++
CFLAGS = -g -Wall -std=c++11
SRC = src
INCLUDES = include
TARGET = main
all: $(TARGET)
$(TARGET): $(SRC)/$(TARGET).cpp pugi/pugixml.cpp
$(CC) $(CFLAGS) -I $(INCLUDES) -o $@ $^
clean:
$(RM) $(TARGET)
但是,当我尝试在此更改后运行我的 Makefile 时,出现此错误:
make: *** No rule to make target `pugi/pugixml.cpp', needed by `main'. Stop.
我真的不确定我应该做什么。pugi 应该有自己的 Makefile 来单独构建它,还是我应该在我的 Makefile 中给它不是自己的"目标"?
编辑这是我的文件系统:
- 根/生成文件
- root/src/main.cpp
- root/include/pugi/pugixml.hpp
- root/include/pugi/pugixml.cpp
- root/include/pugi/pugiconfig.hpp
在 Makefile 中,
您尝试编译pugi/pugixml.cpp
文件,但在文件系统上它位于 include/pugi/pugixml.cpp
中(相对于 Makefile 本身)。您应该:
创建
root/pugi
目录并在那里放置pugixml.cpp
文件或
或者将
pugi/pugixml.cpp
替换为 Makefile 中的include/pugi/pugixml.cpp
(但将源文件保留在子目录中include/
是个坏主意)。
相关文章:
- 制作文件:没有规则来制定目标:如何设置正确的规则?
- antlr 规则上下文是否可以独立于目标
- C++ 如何将两个 makefile 对象目标规则(位于另一个文件夹中)合并到一个目标/规则中?
- Cassandra C++ MacOS High Sierra上的驱动程序:make:没有规则来制作目标
- 没有规则来设定目标'/usr/lib/x86_64-linux-gnu/libboost_filesystem.so'
- 没有规则来制作目标.o,为什么?
- 无需规则即可将目标设为 .moc
- 没有规则来制作目标'src/main/jni/Build.config'。停
- 制作:没有实现目标的规则 - 找不到源文件
- 没有规则来使目标"TBB_ENV_LIB_DEBUG-NOTFOUND","lib/libopencv_core.so.3.2.0"需要
- 错误“没有规则实现目标……”
- 源外生成与目标文件的规则不匹配
- 没有规则来设定目标.这是什么
- 没有要成为目标的规则:代码块
- 编译Cyanoboot:没有规则来实现目标
- 链接器命令 - 没有为第三方库设定目标的规则
- 生成文件失败,错误没有规则来设定目标
- EclipseCDT:没有使目标全部成为目标的规则
- make:没有规则来设定目标.日食错误
- make[2]: *** 没有规则在 CGAL 中将目标 '/usr/lib/i386-linux-gnu/libmpfr.so'