Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS on Debian: connect to MSSQL with ODBC fails

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Peter C. Norton" <spacey-freetds.org AT ssr.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS on Debian: connect to MSSQL with ODBC fails
  • Date: Wed, 1 Dec 2010 11:52:11 -0500

On Wed, Dec 01, 2010 at 05:08:45PM +0100, Boniforti Flavio wrote:
> Hello Peter.
>
> > Start by using the unixODBC tool "osql" which is a shell
> > script which tries to discover the correct parameters to pass to isql.
>
> My /etc/odbc.ini:
>
> [sqlexpress]
> Driver = FreeTDS
> #Driver = /usr/lib/odbc/libtdsodbc.so
> Port = 1433
> Description = MS SQL Server 2005 Express
> Trace = Yes
> Server = exchange.piramide.local
> Database = Piramide_Informatica
>
> Then I try to connect with osql:
>
> root@ticket:~# osql -S sqlexpress -U sa -P XXXXXX
> osql: error: no potential directory strings in "/usr/bin/isql"
> isql strings are:
> + /lib/ld-linux.so.2
>
> The latter file *does exist*:
>
> root@ticket:~# locate ld-linux.so.2
> /lib/ld-linux.so.2
> /lib/i686/cmov/ld-linux.so.2
>
> Using strace I got:
>
> root@ticket:~# strace -e connect osql -S sqlexpress -U sa -P cheope
> --- SIGCHLD (Child exited) @ 0 (0) ---
> --- SIGCHLD (Child exited) @ 0 (0) ---
> --- SIGCHLD (Child exited) @ 0 (0) ---
> --- SIGCHLD (Child exited) @ 0 (0) ---
> --- SIGCHLD (Child exited) @ 0 (0) ---
> osql: error: no potential directory strings in "/usr/bin/isql"
> isql strings are:
> --- SIGCHLD (Child exited) @ 0 (0) ---
> --- SIGCHLD (Child exited) @ 0 (0) ---
> + /lib/ld-linux.so.2
> --- SIGCHLD (Child exited) @ 0 (0) ---
>
> Where may the problem be?

I'm making some suggestions here without knowing enough about your
environment. Please take this with a grain of salt, unixODBC does a
lot of dynamic linking/loading magic to allow for multiple library
providers, etc.

That said, installing your odbc library into /usr/lib/odbc is probably
putting it outside the normal search path of the dynamic linker. For
the sake of testing, can you try running:

env LD_LIBRARY_PATH=/usr/lib/odbc osql -S sqlexpress -U sa -P XXXXXX

though it looks like osql is using strings on the isql binary instead
of something more sensbile like ldd, objdump -x, etc. So this could
get more complex.

However, in practice using that should allow isql to find the library.
If not, then you need to muck around with building with linker flags
like -Wl,-R/usr/lib/odbc when you link your isql so that osql can find
it, or setting your LD_LIBRARY_PATH and LD_RUN_PATH so that ld uses
the run path when linking, and so the paths get saved in the binary.

BTW, did you build your freetds with the --with-unixodbc=/usr/lib/odbc
or something similar to enable it?

-Peter




Archive powered by MHonArc 2.6.24.

Top of Page