SQL Server On Mamp -

Adam Leder 21 Reputation points
2022-01-21T17:56:16.267+00:00

I've gone through the following process:

I Ran these commands:

brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install autoconf automake libtool
brew install msodbcsql17 mssql-tools
brew install unixodbc

sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install sqlsrv

sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install pdo_sqlsrv

Added these two lines to the MAMP PHP config file in the Dynamic Extensions section (Languages > PHP > Enable other extensions):

extension=/Applications/MAMP/bin/php/php7.4.21/lib/php/extensions/no-debug-non-zts-20190902/pdo_sqlsrv.so

extension=/Applications/MAMP/bin/php/php7.4.21/lib/php/extensions/no-debug-non-zts-20190902/sqlsrv.so

However, every time the servers are started the following errors are fired, outputting to the php error log:

[21-Jan-2022 17:43:43 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so' (tried: /Applications/MAMP/bin/php/php7.4.21/lib/php/extensions/no-debug-non-zts-20190902/pdo_sqlsrv.so (dlopen(/Applications/MAMP/bin/php/php7.4.21/lib/php/extensions/no-debug-non-zts-20190902/pdo_sqlsrv.so, 0x0009): symbol not found in flat namespace '_SQLAllocHandle'), /Applications/MAMP/bin/php/php7.4.21/lib/php/extensions/no-debug-non-zts-20190902/pdo_sqlsrv.so.so (dlopen(/Applications/MAMP/bin/php/php7.4.21/lib/php/extensions/no-debug-non-zts-20190902/pdo_sqlsrv.so.so, 0x0009): symbol not found in flat namespace '_SQLAllocHandle')) in Unknown on line 0
[21-Jan-2022 17:43:43 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /Applications/MAMP/bin/php/php7.4.21/lib/php/extensions/no-debug-non-zts-20190902/sqlsrv.so (dlopen(/Applications/MAMP/bin/php/php7.4.21/lib/php/extensions/no-debug-non-zts-20190902/sqlsrv.so, 0x0009): symbol not found in flat namespace '_SQLAllocHandle'), /Applications/MAMP/bin/php/php7.4.21/lib/php/extensions/no-debug-non-zts-20190902/sqlsrv.so.so (dlopen(/Applications/MAMP/bin/php/php7.4.21/lib/php/extensions/no-debug-non-zts-20190902/sqlsrv.so.so, 0x0009): symbol not found in flat namespace '_SQLAllocHandle')) in Unknown on line 0

Anyone have an idea what's triggering the error for "symbol not found in flat namespace '_SQLAllocHandle'" and how to resolve it?

Thanks!

SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. George Nagy 156 Reputation points
    2022-01-25T14:57:53.06+00:00

    It sounds like there are dependency issues relating to the "msodbcsql17" package. There are many possible scenarios as to how the dependency issue could have occurred. A solution that will work in most cases is uninstalling and reinstalling Homebrew. This will ensure that Homebrew is installed at the correct location for the type of Mac you're on (Apple Silicone vs Intel) and any dependency issues will be fixed.

    First step is to take note of the currently installed brew packages by running:

    brew list  
    

    You should see a list similar to this (yours will have different packages listed):

    168307-screen-shot-2022-01-25-at-93959-am.png

    Take a screenshot of the returned list so you know what needs to be reinstalled (as removing Homebrew will also remove all of the installed packages).

    Then run this command to download the Homebrew removal script:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"  
    

    Run the uninstaller:

    /bin/bash uninstall.sh  
    

    Take note of any folders the uninstaller indicates will need to be removed manually. Go ahead and remove those folders too.

    Now reinstall Homebrew:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"  
    

    Note the instructions once the install completes - you need to run two commands to add brew to the PATH.

    From there, reinstall the packages that were displayed from from the 'brew list' command previously.

    To reinstall the SQL Server drivers, run:

    brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release  
    brew update  
    brew install autoconf automake libtool  
    brew install msodbcsql17 mssql-tools  
    brew install unixodbc  
    

    Intel Mac

    sudo pecl install sqlsrv  
    sudo pecl install pdo_sqlsrv  
    

    Apple Silicone Mac

    sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install sqlsrv  
    sudo CXXFLAGS="-I/opt/homebrew/opt/unixodbc/include/" LDFLAGS="-L/opt/homebrew/lib/" pecl install pdo_sqlsrv  
    

    And one final command to fix an issue on Apple Silicone Macs:

    ln -sfn /opt/homebrew/Cellar/openssl@1.1/1.1.1m /opt/homebrew/opt/openssl

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.