Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dyld: lazy symbol binding failed: Symbol not found: _clock_gettime - in mongodb laravel

I am using Laravel 5.4 version to implement mongodb CRUD operation using link. I am using Mac OS El Captain 10.11. I have installed mongodb.so extension with php version 7.1.16

While i am trying getting eloquent connection it throws me ERR_EMPTY_RESPONSE

I have digg in details an found following error log in Apache during restart the MAMP server

 Mon Aug 28 10:22:14 2017] [notice] Graceful restart requested, doing restart
[Mon Aug 28 10:22:15 2017] [notice] Digest: generating secret for digest authentication ...
[Mon Aug 28 10:22:15 2017] [notice] Digest: done
[Mon Aug 28 10:22:15 2017] [notice] Apache/2.2.31 (Unix) mod_wsgi/3.5 
 Python/2.7.13 PHP/7.1.1 mod_ssl/2.2.31 OpenSSL/1.0.2j DAV/2 
mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.24.0 configured -- resuming normal operations
[Mon Aug 28 10:22:15 2017] [notice] FastCGI: process manager initialized (pid 4233)
dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
Referenced from: 
/Applications/MAMP/bin/php/php7.1.1/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so
Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _clock_gettime
Referenced from: 
/Applications/MAMP/bin/php/php7.1.1/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so
Expected in: /usr/lib/libSystem.B.dylib

dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
Referenced from: 
 /Applications/MAMP/bin/php/php7.1.1/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so
 Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _clock_gettime
Referenced from: 
/Applications/MAMP/bin/php/php7.1.1/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so
 Expected in: /usr/lib/libSystem.B.dylib

This screenshot shows the details of mongodb extension enter image description here I have searched online for error dyld: lazy symbol binding failed: Symbol not found: _clock_gettime and found this answer. I have applied all steps which i mentioned, but unable to fix the issue.

Please someone help me to get rid of this.

like image 913
Chintan7027 Avatar asked Aug 23 '17 07:08

Chintan7027


2 Answers

First of you need to update your os to macOS Sierra, (I am using version 10.12)

clock_gettime was not provided in El Capitain,

Apple has (finally) introduced the clock_gettime posix API in Sierra. Our configure script detects this and enable usage of it. Since the binary isn't executed on Sierra, but instead on El Capitain where this functionality doesn't exist, the linking in runtime fails. Using the workaround you suggest is not a good solution. This might seemingly work, but it is not impossible that you get strange failures at a later time since the binary isn't compiled for the system it is executing on.

Reference From : https://bugs.erlang.org/browse/ERL-256

like image 129
Mehul Panchasara Avatar answered Nov 18 '22 09:11

Mehul Panchasara


Latest versions of php{XX}-mongodb installed from homebrew rely on the use of a OS X 10.12 specific Symbol called _clock_gettime, which did not exists in OS X < 10.12.

Upgrading your system will solve this problem, but you might have some valid reasons to not wish to upgrade it.

There is a pull-request currently being Work-In-Progress to preserve the OS X 10.11 compatibility :

https://github.com/Homebrew/homebrew-php/issues/3737

https://github.com/Homebrew/homebrew-php/pull/3890

While this is not accepted, you can hack the phpXX-mongodb formula yourself, as nicely suggested by @adocwang here :

(Be sure to install xcode-select tools first)

sudo xcode-select --install
# Or if you already installed it
softwareinstall --install -a

Then edit the php{XX}-mongodb formula (that'll be php71-mongogb, php56-mongodb, or whatever PHP version you're using)

brew edit php{XX}-mongodb

Find the line of "def install", and replace

def install
  Dir.chdir "mongodb-#{version}" unless build.head?

By

def install
  Dir.chdir "mongodb-#{version}" unless build.head?

  if MacOS.version == "10.11" && MacOS::Xcode.installed? && MacOS::Xcode.version >= "8.0"
    inreplace %w[src/libbson/src/bson/bson-clock.c], "HAVE_CLOCK_GETTIME", "UNDEFINED_GIBBERISH"`
  end

Then force the reinstallation of this formula from source

brew reinstall -s php{XX}-mongodb
like image 1
Flo Schild Avatar answered Nov 18 '22 10:11

Flo Schild