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

11,565

Solution 1

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

Solution 2

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
Share:
11,565

Related videos on Youtube

Chintan7027
Author by

Chintan7027

Helping people by means of Technology.

Updated on September 17, 2022

Comments

  • Chintan7027
    Chintan7027 over 1 year

    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.

  • Chintan7027
    Chintan7027 over 6 years
    Thanks, @Mehul Panchasara I am afraid, why i have to upgrade my OS just for one clock_gettime binaray
  • Mehul Panchasara
    Mehul Panchasara over 6 years
    @Chintan7027 Upgrading your OS will help to install libraries which are missing in your current OS, You can install those libraries manually but it would be a tedious task though.
  • Flo Schild
    Flo Schild over 6 years
    How can "Upgrade your system" be a valid answer?
  • cjm
    cjm about 4 years
    Upgrading my system is out of the question because my hardware is too old for anything newer than El Cap.