Skip to Content.
Sympa Menu

freetds - Re: [freetds] Cross compilation with mingw

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Cesare Leonardi <celeonar AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Cross compilation with mingw
  • Date: Mon, 18 Jul 2011 15:27:34 +0200

2011/7/18 Frediano Ziglio <freddy77 AT gmail.com>:
> you didn't specify the right "host", should be the executable prefix,
> I have a i586-mingw32msvc-gcc on my machine so I have to use
> --host=i586-mingw32msvc during configure.

Aaah, thank you very much Frediano. Now i've finally got the meaning
of the --host options. From the autoconf manual wasn't clear to me.
And thanks to this i've done a big step ahead: freetds now compiles
correctly under both Linux (mingw) and Windows (cygwin+mingw) and
produce the executable utils and the DLL. But i'm not able to connect
neither with PHP nor with the tsql i've built. Well, with tsql there's
a scenario where i can connect...

This is what i've done.
On Debian:
./configure --host=i686-w64-mingw32 --with-tdsver=7.0
make

Copied the following files in a temporary folder under a Win2000 pc:
src/odbc/.libs/libtdsodbc-0.dll
src/apps/.libs/tsql.exe

Taking as a reference win32/installfreetds.bat, i've renamed
libtdsodbc-0.dll in FreeTDS.dll and copied it under %windir%\system32,
then launched this command:
ODBCCONF INSTALLDRIVER "FreeTDS|Driver=FreeTDS.dll|Setup=FreeTDS.dll||"

On a first attempt i've also launched the following commands, as
reported in installfreetds.bat, but i was stuck with an error message
from tsql:
ODBCCONF CONFIGDRIVER "FreeTDS" "APILevel=1"
ODBCCONF CONFIGDRIVER "FreeTDS" "ConnectFunctions=YYY"
ODBCCONF CONFIGDRIVER "FreeTDS" "DriverODBCVer=02.50"
ODBCCONF CONFIGDRIVER "FreeTDS" "FileUsage=0"
ODBCCONF CONFIGDRIVER "FreeTDS" "SQLLevel=1"
ODBCCONF CONFIGDRIVER "FreeTDS" "CPTimeout=60"

The error message was:
Error 20002 (severity 9): Adaptive Server connection failed

Without the above commands, i added a system DSN in ODBC control panel
with these settings:
DSN Name: test
Protocol Version: TDS 7.0
Server Address: the FQDN address of my datadase
Server port: 1433
database: the name of my database

Now if i launch:
tsql -H DbAddressFQDN -p 1433 -U user
It ask me for a password and then at the prompt i can enter SQL
commands successfully. So it works.

But i get error if i attempt to use the "test" DSN i've created:
tsql -S test -U user
Password:
locale is "Italian_Italy.1252"
using default charset "CP1252"
Error 20009 (severity 9):
Unable to connect: Adaptive Server is unavailable or does not exist
OS error 10061, "Unknown error"
There was a problem connecting to the server

And with PHP + PDO_ODBC i cannot connect:
new
PDO("odbc:Driver=FreeTDS;Server=DbAddressFQDN;Database=db;Uid=user;Pwd=pass;");
PDOException: SQLSTATE[08001] SQLDriverConnect: 0 [FreeTDS][SQL
Server]Unable to connect to data source.

Neither if i use the ODBC DSN:
new PDO("test", "user", "pass");
PDOException: invalid data source name

Any idea where i'm doing wrong? I feel i'm near the solution... ;-)
Note that i haven't created any freetds.conf since from the latest
docs seems to be unnecessary if i use a proper connect string. And i
suppose that also the ODBC DSN in the control panel is superflous. Am
i right?

If i will be able to use my compiled freetds DLL under Windows, and if
you think it can be useful, i'll be happy to post the complete
procedure i've followed, so that it could be integrated in the user
guide (after correcting my bad english).

Ciao.

Cesare.




Archive powered by MHonArc 2.6.24.

Top of Page