使用Makefile

时间:2018-01-15 22:04:45

标签: c++ xcode macos boost

我正在尝试分叉程序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上,我的标题搜索路径为"$PROJECT_DIR"/include /usr/local/include /usr/local/boost/include。我的图书馆搜索路径为/usr/local/lib/usr/local/boost/liblibboost_program_options.dyliblibgmp.dyliblibgmpxx.dylib位于我的“Link Binary With Libraries”中。我还将三个库复制到$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)

编辑:我已经重构了将大多数法语单词翻译成英语的程序。因此,这些词语已被改变。

1 个答案:

答案 0 :(得分:2)

查看Project Navigator。您应该在几个地方看到文件是否正在编译和链接。

enter image description here

上图显示了Project Navigator。 Build Phases将显示文件是否正在编译。

您需要检查的下一件事是查看文件检查器。它会显示文件所属的目标。

enter image description here