Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngx_openresty-1.10.24 does not build under OSX #3

Closed
onyxraven opened this issue Jan 4, 2012 · 34 comments
Closed

ngx_openresty-1.10.24 does not build under OSX #3

onyxraven opened this issue Jan 4, 2012 · 34 comments

Comments

@onyxraven
Copy link

When linking the final objs/nginx,

Undefined symbols for architecture x86_64:
"_pcre_free_study", referenced from:
_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_cleanup_pcre_study_data in ngx_http_lua_regex.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [objs/nginx] Error 1

this was configured with a plain './configure' line.

@onyxraven
Copy link
Author

Note, 1.10.39 does work. Maybe this is already fixed.

@agentzh
Copy link
Member

agentzh commented Jan 5, 2012

On Wed, Jan 4, 2012 at 11:25 PM, Justin Hart
reply@reply.github.com
wrote:

When linking the final objs/nginx,

Undefined symbols for architecture x86_64:
 "_pcre_free_study", referenced from:
     _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_cleanup_pcre_study_data in ngx_http_lua_regex.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [objs/nginx] Error 1

this was configured with a plain './configure' line.

Thank you for the report. Could you please try the latest devel
version of ngx_openresty on your side? The latest devel version is
1.0.10.39, which can be downloaded here:

http://openresty.org/#Download

Thanks!
-agentzh

@agentzh
Copy link
Member

agentzh commented Jan 5, 2012

On Thu, Jan 5, 2012 at 10:20 AM, agentzh agentzh@gmail.com wrote:

Thank you for the report. Could you please try the latest devel
version of ngx_openresty on your side? The latest devel version is
1.0.10.39, which can be downloaded here:

   http://openresty.org/#Download

If the problem persists, please check that if you have multiple
versions of PCRE installed in your system. It seems that the PCRE
headers and PCRE library files do not match in your system's default
search path. If it's indeed the case, please fix it by explicitly
specify the search paths for headers and libraries, like this:

./configure --with-cc-opt="-I/path/to/pcre/include"

--with-ld-opt="-L/path/to/pcre/lib" ...

Regards,
-agentzh

@agentzh
Copy link
Member

agentzh commented Jan 5, 2012

Okay, given that 1.0.10.39 works for you, I'm closing this ticket :)

@agentzh agentzh closed this as completed Jan 5, 2012
@nkhine
Copy link

nkhine commented Jan 29, 2012

hello,
just to confirm that on an OSX 1.0.10.40 with Homebrew works by doing the following:

☺  brew info pcre                                                                                                                                         ""
pcre 8.21
http://www.pcre.org/
/usr/local/Cellar/pcre/8.21 (126 files, 3.1M)
http://github.com/mxcl/homebrew/commits/master/Library/Formula/pcre.rb

~/Packages/ngx_openresty-1.0.10.44

☺ ./configure  --with-cc-opt="-I/usr/local/Cellar/pcre/8.21/include" --with-ld-opt="-L/usr/local/Cellar/pcre/8.21/lib"
☺ make
☺ make install

☺ vim ~/.zshrc # add /usr/local/openresty/nginx/sbin to the path
☺ source ~/.zshrc
☺ nginx -v
nginx: nginx version: ngx_openresty/1.0.10.44

@agentzh
Copy link
Member

agentzh commented Jan 29, 2012

On Sun, Jan 29, 2012 at 5:36 PM, Norman Khine
reply@reply.github.com
wrote:

hello,
just to confirm that on an OSX 1.0.10.40 with Homebrew works by doing the following:

Thank you for the information :)

Best regards,
-agentzh

@jtarchie
Copy link

With ngx_openresty-1.2.1.14, this issue is occurring again. I followed the recommended steps for pcre and adding to ./configure, but still end up with the following:

... ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make[2]: *** [objs/nginx] Error 1 make[1]: *** [build] Error 2 make: *** [all] Error 2

@agentzh
Copy link
Member

agentzh commented Sep 21, 2012

Hello

On Thu, Sep 20, 2012 at 9:04 PM, JT Archie notifications@github.com wrote:

With ngx_openresty-1.2.1.14, this issue is occurring again. I followed the recommended steps for pcre and adding to ./configure, but still end up with the following:
ld: symbol(s) not found for architecture x86_64

It is very likely that your PCRE header files and library files do not match.

Please ensure that your PCRE installation is sane. Alternatively you
can build a custom PCRE installation under some locations, like,
/opt/pcre/, or you can just let nginx build the PCRE source for you
via ./configure --with-pcre=/path/to/your/pcre/source/tree.

Best regards,
-agentzh

@jtarchie
Copy link

That was it. Thanks.

@skubot
Copy link

skubot commented Dec 30, 2012

Thanks @agentzh, --with-pcre worked for me as well.

@sathishvc
Copy link

Thanks @nkhine.

I was using rvmsudo passenger-install-nginx-module to install nginx on OS X and was getting the same error. Adding the configuration parameters --with-cc-opt="-I/usr/local/Cellar/pcre/8.32/include" --with-ld-opt="-L/usr/local/Cellar/pcre/8.32/lib" during the customized installation of nginx worked for me too.

@motopig
Copy link

motopig commented May 19, 2013

thanks @nkhine

@laghatea
Copy link

I can't believe I have spent entire day on this bug. I have tried all the fixes suggested above,but this error msg. tells me that openresty is not configured properly. -

nginx: [emerg] unknown directive "echo" in /usr/local/etc/nginx/nginx.conf:45

@agentzh
Copy link
Member

agentzh commented Apr 21, 2014

@laghatea That error message means the ngx_echo module is not included in the nginx server you're trying to start. Because ngx_echo module is enabled in ngx_openresty by default, it is very likely that you're starting the wrong nginx server (maybe you have multiple nginx installations in the same box?).

Note that by default, the nginx executable installed by openresty is located at /usr/local/openresty/nginx/sbin/nginx. You can use the absolute path to start the nginx server.

@liuyu121
Copy link

Hey there are some tips for issues like this.

I use the CONFIGURE to build the openresty:

./configure   --prefix=/usr/local/openresty --with-pcre=/Users/liuyu/learn/nginx/ngx_openresty-1.5.12.1/pcre-8.34  --with-openssl=/Users/liuyu/learn/nginx/ngx_openresty-1.5.12.1/openssl-1.0.1f

And the get the ERROR:


  "_sk_value", referenced from:

      _ngx_ssl_stapling in ngx_event_openssl_stapling.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: *** [objs/nginx] Error 1

make[1]: *** [build] Error 2

make: *** [all] Error 2

And just use:

export KERNEL_BITS=64

Reinstall !

Done!

Good Luck.

@Paxa
Copy link

Paxa commented Apr 15, 2015

Seems like same error in nginx itself
http://trac.nginx.org/nginx/ticket/94
Reason is it takes headers from /usr/local/include/, dylib from /usr/lib

@agentzh
Copy link
Member

agentzh commented May 8, 2015

Please read the official documentation for instructions of installing OpenResty on Mac OS X:

http://openresty.org/#Installation

Essentially, it's as simple as

brew install pcre
./configure \
             --with-cc-opt="-I/usr/local/include" \
             --with-ld-opt="-L/usr/local/lib" \
             -j4
make -j4
sudo make install

where we assume that your system has 4 spare CPU cores.

Good luck!

@grasses
Copy link

grasses commented Jul 10, 2015

I have installed pcre, and configure command is:

sudo ./configure --with-openssl=bundle/openssl --with-cc-opt="-I/usr/local/Cellar/pcre/8.37/include" --with-ld-opt="-L/usr/local/Cellar/pcre/8.37/lib"

still return error:

meanwhile it has a warning:

WARNING! If you wish to build 64-bit library, then you have to
invoke './Configure darwin64-x86_64-cc' manually.
You have about 5 seconds to press Ctrl-C to abort.

@grasses
Copy link

grasses commented Jul 10, 2015

then I let nginx build the PCRE source,

sudo ./configure --with-openssl=bundle/openssl --with-pcre=bundle/pcre-8.37

return same error.
so sad.

@agentzh
Copy link
Member

agentzh commented Jul 10, 2015

@grasses A quick google search found this solution:

http://forum.nginx.org/read.php?2,256012,256064#msg-256064

@agentzh
Copy link
Member

agentzh commented Jul 10, 2015

@grasses I've tested on my macbook (Mac OS X 10.10.4) the aforementioned work-around works:

export KERNEL_BITS=64
./configure --with-cc-opt='-I/usr/local/Cellar/pcre/8.37/include/' \
       --with-ld-opt='-L/usr/local/Cellar/pcre/8.37/lib' \
       --with-openssl=$HOME/work/openssl-1.0.2d -j9
make -j9
sudo make install

BTW, only use sudo for make install otherwise the environments may change.

@agentzh
Copy link
Member

agentzh commented Jul 10, 2015

@grasses It seems that this is a known issue with recent versions of OpenSSL on Mac OS X. And it only happens when you try to use the --with-openssl=PATH option to build OpenSSL from source directly via NGINX's build system (yes, it's not specific to OpenResty, but a general NGINX issue).

I'll incorporate the work-around directly into OpenResty's build system so that the users will no longer have to worry about the details.

Thanks for the report!

agentzh added a commit that referenced this issue Jul 10, 2015
…en the ./configure option --with-pcre=PATH was used and the openssl source was recent enough. thanks grasses for the report in #3.
@grasses
Copy link

grasses commented Jul 10, 2015

@agentzh
It works now!! thanks !!

Sorry, something went wrong.

@agentzh
Copy link
Member

agentzh commented Jul 10, 2015

@grasses Glad it works for you now. You're welcome :)

Sorry, something went wrong.

justicel pushed a commit to justicel/openresty-ppa that referenced this issue Aug 26, 2015
* 'master' of https://github.com/openresty/ngx_openresty: (181 commits)
  bumped version to 1.9.3.1.
  bumped version to 1.9.3.1rc1.
  updated the tests to reflect recent changes.
  upgraded the nginx core to 1.9.3.
  bugfix: ./configure --help: fixed the usage text for the --with-debug option. thanks Kipras Mancevičius for the report.
  bugfix: link failures with openssl might happen on 64-bit Mac OS X when the ./configure option --with-pcre=PATH was used and the openssl source was recent enough. thanks grasses for the report in openresty#3.
  upgraded ngx_postgres to 1.0rc7.
  fixed a compilation error when both the dtrace static probes and --with-threads are specified.
  updated the test suite to reflect recent changes; also bumped version to 1.9.2.1 RC1.
  removed the --with-rtsig_module option from the usage info of ./configure.
  ./configure: added --with-threads to usage; also added --with-threads test to dist-check.
  upgraded the nginx core to 1.9.2.
  updated tests to reflect recent changes.
  bumped version to 1.7.10.2.
  upgraded resty-cli to 0.03.
  Updated repository link in the README
  ./configure: fixed the --without-http_rewrite_module option by disabling NDK automatically; also automatically disable the ngx_encrypted_session module when NDK is disabled.
  util/dist-check: the nogzip build now also disables ssl and pcre.
  updated tests to reflect recent changes.
  bumped version to 1.7.10.2rc1.
  ...
@Bingnan
Copy link

Bingnan commented Nov 20, 2015

Check pcre and openssl path by "brew info pcre" and "brew info openssl";

then according to the result, specify the path for both of them in configure command:

./configure --with-cc-opt="-I/usr/local/Cellar/pcre/8.37/include -I/usr/local/opt/openssl/include" --with-ld-opt="-L/usr/local/Cellar/pcre/8.37/lib -L/usr/local/opt/openssl/lib"

@bsyk
Copy link

bsyk commented Dec 18, 2015

I had to
export MACOSX_DEPLOYMENT_TARGET=10.9
to get the configure script to use the right versions of the libraries.

From the LuaJit project installation page :

Note for OSX: if the MACOSX_DEPLOYMENT_TARGET environment variable is not set, then it's forced to 10.4.

@agentzh
Copy link
Member

agentzh commented Dec 19, 2015

@bsyk Thanks for the info. Maybe we should set the environment automatically in OpenResty's build system.

agentzh added a commit that referenced this issue Dec 19, 2015
…T to the current Mac OS X version unless the env is already set. thanks bsyk for the report in #3.
@agentzh
Copy link
Member

agentzh commented Dec 19, 2015

@bsyk Fixed in git master.

@larkin-keith
Copy link

when I insert ./configure
-bash: ./configure: No such file or directory

@agentzh
Copy link
Member

agentzh commented Dec 24, 2015

@lavenkin Seems like you are in the wrong current working directory. Try the following commands (tested on my Macbook Pro):

brew install pcre
wget https://openresty.org/download/ngx_openresty-1.9.7.1rc2.tar.gz
tar -xvf ngx_openresty-1.9.7.1rc2.tar.gz
cd ngx_openresty-1.9.7.1rc2/
./configure --with-cc-opt="-I/usr/local/include" --with-ld-opt="-L/usr/local/lib" -j5
make -j5
sudo make install

@wynelu
Copy link

wynelu commented Jan 17, 2016

I'm using OX EI Capitan 10.11.2, use brew install openssl and pcre, then configure generate error, then using brew link --force openssl(don't know it helps), then compile specify path like follows..

./configure --with-cc-opt='-I/usr/local/Cellar/pcre/8.38/include/ -I/usr/local/Cellar/openssl/1.0.2e_1/include/' --with-ld-opt='-L/usr/local/Cellar/pcre/8.38/lib -L/usr/local/Cellar/openssl/1.0.2e_1/lib' -j2

then make works fine.
just record this to some newers like me.

@bungle
Copy link
Member

bungle commented Jan 18, 2016

@wynelu, I use brew and:
--with-cc-opt="-I/usr/local/include -I/usr/local/opt/openssl/include"
--with-ld-opt="-L/usr/local/lib -L/usr/local/opt/openssl/lib"

@larkin-keith
Copy link

@agentzh, Yes It works!

@LittleShrimp1987
Copy link

$: ln -s /usr/local/Cellar/pcre/8.38 /usr/local/opt/pcre
works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests