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"

你可能感兴趣的:(ngx_openresty mac os x上面编译出错)