ngx_openresty mac os x上面编译出错

When building OpenResty (the excellent Lua add-on for nginx) on OS/X I got the following error:

Undefined symbols for architecture x86_64:
  "_pcre_free_study", referenced from:
      _ngx_pcre_free_studies in ngx_regex.o
      _ngx_http_lua_ngx_re_match in ngx_http_lua_regex.o
      _ngx_http_lua_ngx_re_gmatch in ngx_http_lua_regex.o
      _ngx_http_lua_ngx_re_sub_helper in ngx_http_lua_regex.o
      _ngx_http_lua_ngx_re_gmatch_cleanup in ngx_http_lua_regex.o
      _ngx_http_lua_ngx_re_gmatch_gc in ngx_http_lua_regex.o
      _ngx_http_lua_ngx_re_gmatch_iterator in ngx_http_lua_regex.o
      ...
ld: symbol(s) not found for architecture x86_64

To cut a long story short, download the latest version of pcre (PCRE – Perl Compatible Regular Expressions) from ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/, extract it to a directory, say /Users/me/pcre-8.21/ and then from the ngx-openresty source directory run configure with:

./configure --with-luajit --with-pcre=/Users/me/pcre-8.21/

all will be well…

—– update from Sept 2013:

I realised that perhaps a better way to install PCRE would be to install homebrew on your Mac and then just:

brew install pcre

however, you will need to know where homebrew installed pcre as you will need to add that parameter when running configure. There are several ways of locating a file on the Mac (I’ll refer to the command line only. The grep is since I know it is installed somewhere in /usr/local):

  • mdfind (uses spotlight), for example:
mdfind pcre | grep usr/local
  • a combination of
sudo /usr/libexec/locate.updatedb

and then

locate pcre | grep usr/local
  • or just plain old find:
find /usr/local -name pcre -print

in my case the location was /usr/local/Cellar/pcre/8.33/ so the configure parameters were:

./configure --with-luajit \
            --with-cc-opt="-I/usr/local/Cellar/pcre/8.33/include" \
            --with-ld-opt="-L/usr/local/Cellar/pcre/8.33/lib"

转载于:https://my.oschina.net/tonyyang/blog/170106

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值