Reputation: 1420
I was unable to connect to a MS-SQL server via Microsoft's ODBC driver for Linux. Error messages below:
isql mydsn myuser mypw -v
[01000][unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0' : file not found
The message above isn't telling the whole story though. Let's see what ldd can tell us:
ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0
/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0)
/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0)
[...]
(I'm installing this on a Docker image so that Caravel can connect to MS-SQL databases - see Dockerfile, Docker image for Caravel)
Upvotes: 1
Views: 3511
Reputation: 1420
The commands below will install the correct version of libstdc++.so.6 (based on this answer):
echo 'deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main' > \
/etc/apt/sources.list.d/ubuntu-toolchain-r-test-trusty.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F
apt-get update -y
apt-get upgrade -y
apt-get dist-upgrade -y
So if you're starting from scratch on ubuntu 14.04, these commands will install UnixODBC, Microsoft SQL Server ODBC driver for Linux and all required dependencies:
echo 'deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main' > \
/etc/apt/sources.list.d/ubuntu-toolchain-r-test-trusty.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F && \
apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y && \
apt-get install -y build-essential libssl-dev libffi-dev \
curl ca-certificates libgss3 && \
locale-gen en_US.utf8 && dpkg-reconfigure locales
mkdir -p /tmp/ms-sql && (cd /tmp/ms-sql && curl 'https://download.microsoft.com/download/2/E/5/2E58F097-805C-4AB8-9FC6-71288AB4409D/msodbcsql-13.0.0.0.tar.gz' \
-H 'Referer: https://www.microsoft.com/en-us/download/confirmation.aspx?id=50419' --compressed | \
tar --strip-components=1 -xzv && \
sed -ri -e 's/wget/curl/g' -e's/(\s*)\$\(curl[^)]+\)/\1curl -fsSL "$dm_url" -o "$dm_package_path"/' \
-e '/make install/,$ d' build_dm.sh && echo '(cd $tmp/$dm_dir && make install)' >> build_dm.sh && \
echo YES | ./build_dm.sh --accept-warning --libdir=/usr/lib/x86_64-linux-gnu && \
./install.sh install --accept-license) && \
sed -rie 's/\[.+SQL Server\]/[MS-SQL]/' /etc/odbcinst.ini
Upvotes: 2