Skip to content

Trouble Shooting: Can't build PHP on OS X El Capitan

Yo-An Lin edited this page Oct 20, 2015 · 1 revision

If you encountered the error like below:

_readline_shell_run in readline_cli.o
"_history_list", referenced from:
_zif_readline_list_history in readline.o
"_rl_mark", referenced from:
_zif_readline_info in readline.o
"_rl_pending_input", referenced from:
_zif_readline_info in readline.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: *** [sapi/cli/php] Error 1

Here is an answer from @augustohp:

You should be careful when upgrading to a major version if you want to keep compiling stuff, everything will break specially after heart bleed when Apple solely decided they are better patching openssl and curl by themselves.

Your trace is not useful at all, you did not give the root cause of the link error (just the end of it) but as I said, it is probably curl or openssl (or libxml2). Given the lack of information you will have to try everything that comes up to my mind:

  1. Update XCode tools with xcode-select --install, if that doesn't work (it rarely does), download it manually.
  2. Install/Upgrade homebrew formulas:
    1. brew update to update formulas.
    2. Re-tap homebrew/php so we get their dependenciesbrew tap homebrew/php --repair.
    3. Install all formulas listed on brew deps homebrew/php/php56 --with-gmp.
    4. Upgrade previously installed formulas with brew upgrade.
  3. You will probably have to force link some dependencies (you can link them elsewhere too, probably better but you need to specify the path on the variants):
    1. Link them with brew link --force iconv.
    2. Some I know you will have to: libxml2, curl, icu4c.

I really don't know what will help you, but I have all last versions since 5.3 compiled under El Capitan using phpbrew, haven't tried 7.0 (though doing that now), so I know it works.

PS: Make sure you install a new version with --test 😄 PPS: I am sorry if you use macports.