I've installed mssql-tools and msodbcsql,

And I've symlinked /usr/local/homebrew/lib/libmsodbcsql.13.dylib to /usr/local/lib/libmsodbcsql.13.dylib

But sqlcmd still complains about missing lib,

%> sqlcmd -S IP
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Can't open lib '/usr/local/lib/libmsodbcsql.13.dylib' : file not found.

Any ideas?

  • Some things maybe be unhappy with a symlink, can you try physically copying the file?
    – thrig
    Jun 9 '17 at 18:19
  • @thrig Same result
    – daisy
    Jun 10 '17 at 1:22
  • 1
    Hmm, what does running it under dtruss show?
    – thrig
    Jun 10 '17 at 14:27
  • Thanks @thrig! dtruss is super helpful, I need to symlink /usr/local/homebrew/lib/libodbcinst.2.dylib as well, dtruss pointed that out
    – daisy
    Jun 10 '17 at 14:44
  • Ahh, lies, damned lies, and error messages.
    – thrig
    Jun 10 '17 at 14:48

As @thrig says, I tried to dtruss to debug the problem,

sudo dtruss sqlcmd -S someserver

And from the output, sqlcmd attempts to read /usr/local/lib/libodbcinst.2.dylib and failed.

Adding symlink of libodbcinst.2.dylib solved the problem, so it's actually caused by a missing dependency, sigh


This doesn't happen on all our machines, but we did run into it today. We ran

brew install msodbcsql

We encountered

libmsodbcsql13.dylib not found

We ran

brew link msodbcsql

This resulted in:

4 symlinks created

This fixed the issue for us.

  • Awesome .. this is much better
    – daisy
    Jun 30 '17 at 14:51


First of all try reinstalling the packages again:

brew tap microsoft/msodbcsql https://github.com/Microsoft/homebrew-mssql-release
ACCEPT_EULA=y brew reinstall --no-sandbox msodbcsql mssql-tools

Then if it's still happening, run:

cp -v "$(brew list msodbcsql | grep odbcinst.ini$)" ~/.odbcinst.ini

to copy the INI file which defines the location of SQL ODBC driver.

Bug report: SQL Server : Can't open lib 'ODBC Driver 13 for SQL Server'.

Then test your SQL setup by: sqlcmd -S localhost or isql -v -k <connection-string>.

See: Installing the Microsoft ODBC Driver for SQL Server on Linux and macOS.


$ odbcinst -j # Verify the config.
$ sleep 20 && sqlcmd -S localhost & # Run `sqlcmd` in the background.
$ sudo fs_usage -f filesys | grep -w sqlcmd | grep -e open -e access -e stat64
open              /Users/myuser/.odbcinst.ini                 
access            /usr/local/lib/ODBC Driver 13 for SQL Server
access            /lib>>>>>>>>>>>>>>>>>>>>                    
access            /usr/lib/ODBC Driver 13 for SQL Server      
stat64            ODBC Driver 13 for SQL Server               
stat64            /opt/X11/lib/ODBC Driver 13 for SQL Server  
stat64            /usr/lib/ODBC Driver 13 for SQL Server      

For Linux, see this Anaconda related issue: ODBC Driver 13 for SQL Server can't open lib.

  • This worked for me among all the solutions I read. Thanks. +1
    – user102859
    Jul 11 '19 at 11:08

I ran into the same problem and the dtruss trace produced the same output as described by daisy.

The location of the missing lib is with the unixodbc drivers. You can install those with brew install unixodbc if you don't have them. The link command and paths required for linking on my system were as follows:

ln /usr/local/Cellar/unixodbc/2.3.6/lib/libodbcinst.2.dylib /usr/local/lib/libodbcinst.2.dylib

Obviously, you may have a different version, but it should be located beneath the path /usr/local/Cellar/unixodbc

After adding this link, I am able to connect to my local and remote SQL servers from the terminal. I'm on macOS High Sierra 10.13.5.


Solution: For 13 version need open ssl v 1.0.0 , you can try it.

brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb

  • Welcome to unix SE and hi! I don't quite find how your answer relates to the question. Would mind to elaborate? Aug 7 '20 at 5:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.