Missing libtdsodbc.so in freetds-dev - MSSQL on Ubuntu
Asked Answered
T

3

15

I'm trying to get MSSQL working on Ubuntu 12.04 via ODBC, and I've followed these steps to the letter:

http://jamesrossiter.wordpress.com/2011/03/08/connecting-to-microsoft-sql-server-using-odbc-from-ubuntu-server/

However, this omits both of these files that are pointed at in odbcinst.ini:

Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so

So, I googled a bit and found this:

http://ubuntuforums.org/showthread.php?t=433435&page=2

So I followed those instructions and put libtdsodbc.so in /usr/lib/odbc/, but I still get this error:

Can't open lib '/usr/lib/odbc/libtdsodbc.so' : file not found, SQL state 01000 in SQLConnect

But...

root@ubuntu:/usr/lib/odbc# ls -la
total 552
drwxr-xr-x  2 root root   4096 Aug 19 20:12 .
drwxr-xr-x 62 root root  12288 Aug 19 19:41 ..
-rwxrwxr-x  1 root root 270608 Aug 19 20:00 libtdsodbc.so

I tried chmod 775 on that file, which explains the permissions. Still no luck.

Any ideas? I'm stumped. Would really love to get this working on my Linux box.

EDIT: I'm using Ubuntu 64-bit. I'm betting this is the problem. Hope that helps...

EDIT2: I tried manually getting the 64-bit package from here:

http://www.ubuntuupdates.org/package/core/precise/main/base/tdsodbc

And then I saw there was a file called this:

/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

Woo, maybe a 64-bit version, right?

So I pointed odbcinst.ini at it, and it didn't work.

Trimetrogon answered 20/8, 2012 at 3:13 Comment(2)
Pointing odbcinst.ini to the 64-bit file worked in my situation.Banzai
Alright? It didn't in mine. My answer is below which required some changes to config files.Trimetrogon
T
1

I ended up solving it with the help of this listserv post:

http://mailman.unixodbc.org/pipermail/unixodbc-support/2008-November/001842.html

Except:

Driver = TDS

Should be:

Driver = FreeTDS

That weird 64-bit driver I had to manually find was also relevant, and ignoring freetds.conf was the way to go.

Fun stuff.

Trimetrogon answered 20/8, 2012 at 4:5 Comment(0)
A
24
sudo apt-get install freetds-dev

or

sudo apt-get install tdsodbc

now for 32-bit look in:

/usr/lib/i386-linux-gnu/odbc/libtdsodbc.so

or 64-bit:

/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Analysis answered 12/4, 2013 at 13:11 Comment(2)
I said in the post: "EDIT: I'm using Ubuntu 64-bit."Trimetrogon
/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.soBacksight
C
2

I have this solution:

# apt-get install stuff......

# Then:

LIBTDSODBC_FILE="$(find / | grep libtdsodbc.so | head -1)"
export LIBTDSODBC_FILE
echo "LIBTDSODBC_FILE: '$LIBTDSODBC_FILE'"

LIBTDSS_FILE="$(find / | grep libtdsS.so | head -1)"
export LIBTDSS_FILE
echo "LIBTDSS_FILE: '$LIBTDSS_FILE'"

printf "[freetds]\nDescription     = MS SQL database access with Free TDS\nDriver          = %s\nSetup           = %s\nUsageCount      = 1\n" "${LIBTDSODBC_FILE}" "${LIBTDSS_FILE}" >> /etc/odbcinst.ini \
  && printf '[mssql]\nDescription             = Microsoft SQL Server\nDriver                  = freetds\nDatabase                = database_name\nServerName              = mssql\nTDS_Version             = 8.0\n' >> /etc/odbc.ini \
  && printf '\n[mssql]\n' >> /etc/freetds/freetds.conf \
  && printf "      host = %s\n" "${TDSHOST}" >> /etc/freetds/freetds.conf \
  && printf "      port = %s\n" "${TDSPORT}" >> /etc/freetds/freetds.conf \
  && printf "      tds version = %s\n" "${TDSVER}" >> /etc/freetds/freetds.conf \
  && cat /root/.odbc.ini \
  && cat /etc/odbc.ini \
  && cat /etc/odbcinst.ini

It's working well inside a Docker that is being compiled for AMD64 and ARM64

Conney answered 7/8, 2022 at 15:52 Comment(0)
T
1

I ended up solving it with the help of this listserv post:

http://mailman.unixodbc.org/pipermail/unixodbc-support/2008-November/001842.html

Except:

Driver = TDS

Should be:

Driver = FreeTDS

That weird 64-bit driver I had to manually find was also relevant, and ignoring freetds.conf was the way to go.

Fun stuff.

Trimetrogon answered 20/8, 2012 at 4:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.