在x86_64上编译“fortune”时出错

时间:2013-05-30 21:02:21

标签: macos compilation makefile symbols

我在x86_64机器上。我正在尝试使用其makefile构建fortune,但是我收到有关缺少符号的错误:

cd fortune && make CC='gcc' \
                    CFLAGS='-O2 -DFORTDIR="\"/usr/local/share/games/fortunes\"" -DOFFDIR="\"/usr/local/share/games/fortunes/off\"" -Wall -fomit-frame-pointer -pipe -DHAVE_REGEX_H -DBSD_REGEX -I../util'   \
                    LDFLAGS='-s' LIBS=''
gcc -s -o fortune fortune.o 
ld: warning: option -s is obsolete and being ignored
Undefined symbols for architecture x86_64:
  "_re_comp", referenced from:
      _getargs in fortune.o
  "_re_exec", referenced from:
      _matches_in_list in fortune.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [fortune] Error 1
make: *** [fortune-bin] Error 2

如果我尝试为x86主机构建,我会得到同样的错误:

terences-imac:fortune-mod-9708 MAU$ make host=x86
cd fortune && make CC='gcc' \
                    CFLAGS='-O2 -DFORTDIR="\"/usr/local/share/games/fortunes\"" -DOFFDIR="\"/usr/local/share/games/fortunes/off\"" -Wall -fomit-frame-pointer -pipe -DHAVE_REGEX_H -DBSD_REGEX -I../util'   \
                    LDFLAGS='-s' LIBS=''
gcc -s -o fortune fortune.o 
ld: warning: option -s is obsolete and being ignored
Undefined symbols for architecture x86_64:
  "_re_comp", referenced from:
      _getargs in fortune.o
  "_re_exec", referenced from:
      _matches_in_list in fortune.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [fortune] Error 1
make: *** [fortune-bin] Error 2`

3 个答案:

答案 0 :(得分:2)

显然你正在尝试在Mac OS X上编译,使用标签“osx”和主机名“terences-imac”......

据我所知,原来的财富(ftp://metalab.unc.edu/pub/Linux/games/amusements/fortune/)仅适用于Linux。

有一些BSD端口,您可以查看:https://github.com/ArrantSquid/Fortune-OSX这对我在OSX 10.9(clang和all)上工作

答案 1 :(得分:0)

这就是为什么当人们抱怨autotools时,你应该忽略它们。请记住,autotools适用于用户,而不适用于维护者

您没有指定要构建的操作系统。但是,缺少的符号与正则表达式解析有关,而在您的makefile中,您正在设置-DBSD_REGEX。如果你不在可能是问题的一部分的BSD系统上。

如果您正在使用GNU / Linux,那么查看re_comp手册页,我看到它建议:

#define _REGEX_RE_COMP

因此您可以尝试将-D_REGEX_RE_COMP添加到编译行。

答案 2 :(得分:0)

当前在github上有Mac运气分支的一个分支,该分支已被编译为64位。

https://github.com/tristanmorgan/Fortune-OSX/tree/sixty-four-bit