Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlcmd not able to find a library (libmsodbcsql-17.0.so.1.1) that is there

Tags:

sql

ubuntu

sqlcmd

I'm on Ubuntu 16.04 trying to use sqlcmd launched programmatically from a script to do a SQL query in the VM's cloud.

vm-dev:~$ sudo sqlcmd -S my-db.url.net -d my-db

I keep getting this error:

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.0.so.1.1' : file not found.

But the file is clearly there:

vm-dev:~$ ls /opt/microsoft/msodbcsql17/lib64/

libmsodbcsql-17.0.so.1.1

like image 675
Hack-R Avatar asked Mar 27 '18 16:03

Hack-R


2 Answers

I have same problem, this solution worked for me: you have to downgrade the msodbcsql version,

  1. apt-get remove msodbcsql
  2. apt-cache madison msodbcsql
  3. apt-get install msodbcsql=13.1.9.2-1
  4. apt-cache madison mssql-tools
  5. ACCEPT_EULA=Y apt-get install mssql-tools=14.0.6.0-1
  6. apt-mark hold mssql-tools
  7. apt-mark hold msodbcsql

I got this solution from this link:

https://github.com/Microsoft/msphpsql/issues/684

like image 173
Diyar Avatar answered Oct 06 '22 03:10

Diyar


Just for those who are experiencing the same issue on Ubuntu 18.04 and came here but didn't have the issue solved by the accepted answer, since it's targeted to Ubuntu 16.04, sharing another possible solution, tested with an Ubuntu 18.04 docker container for a Python 3.6 application which relies on Microsoft's odbc driver.

Step 1: Check Library Dependencies

Check if all library dependencies are satisfied using the command ldd. On my environment, the missing libraries were libssl1.0.0 and libgssapi-krb5-2. Below, an example of the command and its output with a missing dependency, grep the output for not found if you will.

$ ldd /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1 

libfoo.so => /path/to/lib/foo/libfoo.so
libbar.so => /path/to/lib/bar/libbar.so
libbaz.so => not found

Step 2: Check Who Provides the Missing Dependency

Check which package provides the missing dependency using dpkg search.

$ dpkg -S libbaz.so

libbaz:amd64: /usr/lib/x86_64-linux-gnu/libbaz.so.1.2.3,

Step 3: Install Missing Dependency

$ sudo apt install libbaz
like image 41
dandev486 Avatar answered Oct 06 '22 01:10

dandev486