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

Created on 6 Mar 2019  路  5Comments  路  Source: microsoft/msphpsql

Hi

I installed SqlServ driver on Ubuntu 18 with php 7.3.

And I got this error

In PHP

Could not connect to PDO: SQLSTATE[01000]: [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1' : file not found. DSN: sqlsrv:Server=60.250.82.248,1433;Database=MD1Mid

In Sqlcmd

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

Follows FAQ to check the dependencies, the output is below.

$ ldd libmsodbcsql-17.3.so.1.1

./libmsodbcsql-17.3.so.1.1: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by ./libmsodbcsql-17.3.so.1.1)
    linux-vdso.so.1 =>  (0x00007ffd863a7000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f966b489000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f966b281000)
    libodbcinst.so.2 => /usr/lib/x86_64-linux-gnu/libodbcinst.so.2 (0x00007f966b066000)
    libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007f966ac22000)
    libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f966a950000)
    libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f966a706000)
    libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007f966a49d000)
    libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f966a298000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9669f16000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9669c0d000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f96699f7000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f96697da000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9669410000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f966ba92000)
    libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f96691e1000)
    libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f9668fdd000)
    libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f9668dd2000)
    libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f9668bce000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f96689b3000)

Is there any suggestion to solve this problem?

Most helpful comment

For Docker Debian 10/9 use this command .If you use docker maybe you need to install dependencies of wget or dpkg and I put this code after install MSS dependecies. You can follow this tutorial https://sunnykim.dev/docker-and-mssql/

RUN wget http://security.debian.org/debian-security/pool/updates/main/o/openssl1.0/libssl1.0.2_1.0.2s-1~deb9u1_amd64.deb \
    && dpkg -i libssl1.0.2_1.0.2s-1~deb9u1_amd64.deb

All 5 comments

The reason is /usr/lib/x86_64-linux-gnu/libstdc++.so.6: versionGLIBCXX_3.4.22' not found`

Follows this step can solve problem: https://stackoverflow.com/a/46613765

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9
sudo apt-get upgrade libstdc++6

For Docker Debian 10/9 use this command .If you use docker maybe you need to install dependencies of wget or dpkg and I put this code after install MSS dependecies. You can follow this tutorial https://sunnykim.dev/docker-and-mssql/

RUN wget http://security.debian.org/debian-security/pool/updates/main/o/openssl1.0/libssl1.0.2_1.0.2s-1~deb9u1_amd64.deb \
    && dpkg -i libssl1.0.2_1.0.2s-1~deb9u1_amd64.deb

Thanks a lot @diegoahg !! I've been searching how to solve this issue for hours, your fix works perfectly!

@diegoahg solution helped for Debian 10, but the link is broken.
Choose download link from: https://packages.debian.org/stretch/amd64/libssl1.0.2/download

Then download/install the deb file as already mentioned:

wget http://ftp.us.debian.org/debian/pool/main/o/openssl1.0/libssl1.0.2_1.0.2u-1~deb9u1_amd64.deb && \
  && dpkg -i libssl1.0.2_1.0.2s-1~deb9u1_amd64.deb

When I use ldd libmsodbcsql-17.7.so.2.1
Error relocating libmsodbcsql-17.7.so.2.1: unsupported relocation type 6
Error relocating libmsodbcsql-17.7.so.2.1: unsupported relocation type 6
Error relocating libmsodbcsql-17.7.so.2.1: unsupported relocation type 6
Error relocating libmsodbcsql-17.7.so.2.1: unsupported relocation type 6
Error relocating libmsodbcsql-17.7.so.2.1: unsupported relocation type 6
Error relocating libmsodbcsql-17.7.so.2.1: unsupported relocation type 6
Error relocating libmsodbcsql-17.7.so.2.1: unsupported relocation type 6
Error relocating libmsodbcsql-17.7.so.2.1: unsupported relocation type 6

Was this page helpful?
0 / 5 - 0 ratings