Mac OS X上的Nauty和Traces

时间:2015-11-05 17:13:48

标签: c xcode macos

我正在尝试使用代码Nauty和Traces http://pallini.di.uniroma1.it/。但是当我编写一个例子时,说nautyex8.c(由包提供),出现以下错误:

Undefined symbols for architecture x86_64:
  "_alloc_error", referenced from:
      _main in nautyex8-54d9da.o
  "_densenauty", referenced from:
      _main in nautyex8-54d9da.o
  "_dispatch_graph", referenced from:
      _main.options in nautyex8-54d9da.o
  "_nauty_check", referenced from:
      _main in nautyex8-54d9da.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我正在使用Mac OS X Yosemite(10.10.5)和Xcode(7.1版)。我相信代码中没有错误,因为它们被广泛使用,所以我猜问题来自我的系统设置。

非常感谢你!

1 个答案:

答案 0 :(得分:1)

我刚刚打开了一个提取请求,以使brew install nauty在OS X上工作:https://github.com/Homebrew/homebrew-core/pull/48701

直到那时,从Nauty / Traces 2.6r12开始,这就是在OS X上构建nautyex8.c的方式。
步骤1是下载代码并构建库:

wget http://pallini.di.uniroma1.it/nauty26r12.tar.gz
tar zxvf nauty26r12.tar.gz
cd nauty26r12
./configure
make
ls -l nauty.a

第2步是编译nautyex8.c,并将其链接到您刚刚构建的库

gcc -O3 nautyex8.c nauty.a
./a.out

您可能忘记了在编译器命令行的末尾添加“ nauty.a”。如果我也这样做,我会得到:

gcc -O3 nautyex8.c
Undefined symbols for architecture x86_64:
  "_alloc_error", referenced from:
      _main in nautyex8-05f086.o
  "_densenauty", referenced from:
      _main in nautyex8-05f086.o
  "_dispatch_graph", referenced from:
      _main.options in nautyex8-05f086.o
  "_nauty_check", referenced from:
      _main in nautyex8-05f086.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

与您描述的症状完全匹配。