我目前正在尝试 fork 该程序 qme-ng 。如果我使用我的 Makefile,似乎一切都会正常。另一方面,如果我想使用 Xcode,就会发生奇怪的事情。
这是我的 Makefile:
CC=g++
CCFLAGS=-D__STDC_LIMIT_MACROS -D__cplusplus -O3 -march=native
LDFLAGS=-L/usr/local/lib -lboost_program_options -lgmp -lgmpxx
SRCDIR=src
INC=-I./include -I/usr/local/include -I/usr/local/boost/include
all: qme-ng
Exception.o: $(SRCDIR)/Exception.cpp
$(CC) $(CCFLAGS) $< $(INC) -c
greenSizeHash.o: $(SRCDIR)/greenSizeHash.cpp
$(CC) $(CCFLAGS) $< $(INC) -c
carquois.o: $(SRCDIR)/carquois.cpp Exception.o
$(CC) $(CCFLAGS) $< $(INC) -c
iceQuiver.o: $(SRCDIR)/iceQuiver.cpp Exception.o
$(CC) $(CCFLAGS) $< $(INC) -c
mutexplorator.o: $(SRCDIR)/mutexplorator.cpp quiver.o Exception.o
$(CC) $(CCFLAGS) $< $(INC) -c
greenexplorator.o: $(SRCDIR)/greenexplorator.cpp greenSizeHash.o iceQuiver.o Exception.o
$(CC) $(CCFLAGS) $< $(INC) -c
greenfinder.o: $(SRCDIR)/greenfinder.cpp iceQuiver.o Exception.o
$(CC) $(CCFLAGS) $< $(INC) -c
mutexploratorSeq.o: $(SRCDIR)/mutexploratorSeq.cpp quiver.o Exception.o mutexplorator.o
$(CC) $(CCFLAGS) $< $(INC) -c
rng.o: $(SRCDIR)/rng.c
$(CC) $(CCFLAGS) $< $(INC) -c
naututil.o: $(SRCDIR)/naututil.c
$(CC) $(CCFLAGS) $< $(INC) -c
nauty.o: $(SRCDIR)/nauty.c
$(CC) $(CCFLAGS) $< $(INC) -c
nautil.o: $(SRCDIR)/nautil.c
$(CC) $(CCFLAGS) $< $(INC) -c
nausparse.o : $(SRCDIR)/nausparse.c
$(CC) $(CCFLAGS) $< $(INC) -c
naugraph.o : $(SRCDIR)/naugraph.c
$(CC) $(CCFLAGS) $< $(INC) -c
nautinv.o : $(SRCDIR)/nautinv.c
$(CC) $(CCFLAGS) $< $(INC) -c
qme-ng: qme-ng.cpp greenexplorator.o greenfinder.o mutexploratorSeq.o mutexplorator.o greenSizeHash.o iceQuiver.o quiver.o Exception.o nautil.o rng.o nauty.o naututil.o nausparse.o naugraph.o nautinv.o
$(CC) $(CCFLAGS) $(INC) $^ $(LDFLAGS) -o $@
clean:
-rm -f *.o qme-ng *.cpp~ src/*.cpp~ include/*.hpp~ src/*.c~ include/*.h~
在 Xcode 上,我的 header 搜索路径为 "$PROJECT_DIR"/include
/usr/local/include
/usr/local/boost/include
>。我的库搜索路径是 /usr/local/lib
和 /usr/local/boost/lib
。 libboost_program_options.dylib
、libgmp.dylib
和 libgmpxx.dylib
位于我的“链接二进制文件与库”中。正如某些网页所建议的那样,我还将这三个库复制到 $PROJECT_DIR
中。
目前我遇到以下 Apple Mach-O 链接器错误:
Undefined symbols for architecture x86_64:
"GreenFinder::find(unsigned long long)", referenced from:
_main in qme-ng.o
"GreenFinder::GreenFinder(IceQuiver, __gmp_expr<__mpz_struct [1], __mpz_struct [1]>, int, int)", referenced from:
_main in qme-ng.o
"GreenExplorator::greenExploration(IceQuiver)", referenced from:
_main in qme-ng.o
"GreenExplorator::GreenExplorator()", referenced from:
_main in qme-ng.o
"GreenExplorator::~GreenExplorator()", referenced from:
_main in qme-ng.o
"MutExploratorSeq::getNbNeighboursMax()", referenced from:
_main in qme-ng.o
"MutExploratorSeq::isAcyclic()", referenced from:
_main in qme-ng.o
"MutExploratorSeq::dumpFiles(char const*)", referenced from:
_main in qme-ng.o
"MutExploratorSeq::MutExploratorSeq()", referenced from:
_main in qme-ng.o
"MutExploratorSeq::~MutExploratorSeq()", referenced from:
_main in qme-ng.o
"IceQuiver::generateGreenVertices()", referenced from:
_main in qme-ng.o
"IceQuiver::print()", referenced from:
_main in qme-ng.o
"IceQuiver::IceQuiver(Quiver)", referenced from:
_main in qme-ng.o
"IceQuiver::IceQuiver(char const*)", referenced from:
_main in qme-ng.o
"IceQuiver::IceQuiver(IceQuiver const&)", referenced from:
_main in qme-ng.o
"IceQuiver::~IceQuiver()", referenced from:
_main in qme-ng.o
"Quiver::Quiver(char const*)", referenced from:
_main in qme-ng.o
"Quiver::Quiver(Quiver const&)", referenced from:
_main in qme-ng.o
"Quiver::Quiver(int, int, int)", referenced from:
_main in qme-ng.o
"Quiver::~Quiver()", referenced from:
_main in qme-ng.o
"Exception::Exception(char const*)", referenced from:
_main in qme-ng.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
已编辑:我重构了程序,将大多数法语单词翻译成英语。因此,这些话已被更改。
最佳答案
关于c++ - 使用 Makefile 运行的程序中出现 Xcode 链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48271305/