This is how I got FreeTDS to compile on Windows 7 Professional with Visual Studio 2008.
1. Install Visual Studio 2008 (a.k.a.: Visual Studio 9.0)
2. Download the FreeTDS 0.91 source tarball and extract it somewhere. I chose C:\Users\marca\src\freetds-0.91
.
3. Open a Visual Studio 2008 Command Prompt.
4. Change to the directory with FreeTDS:
cd C:\Users\marca\src\freetds-0.91
(or whatever you chose)
5. Give this a shot — it will fail probably:
nmake -fNmakefile -nologo apps PLATFORM=win32 CONFIGURATION=debug
6. You will get a bunch of errors that look like this:
c:\users\marca\src\freetds-0.91\include\tds_sysdep_private.h(239) : fatal error C1083: Cannot open include file: 'inttypes.h': No such file or directory
7. Fix the inttypes.h
error — edit win32/config.h
and comment out this line (line 92 for me):
#define HAVE_INTTYPES_H 1
8. If you repeat the above nmake
command, then you’ll get a new error:
c:\program files (x86)\microsoft visual studio 9.0\vc\include\stdio.h (358) : error C3163: '_vsnprintf': attributes inconsistent with previous declaration c:\program files (x86)\microsoft visual studio 9.0\vc\ include\stdio.h(350) : see declaration of '_vsnprintf'
9. Fix the _vsnprintf
error by editing include/tds_sysdep_private.h
and commenting out the second instance of this line (line 96 for me):
#define vsnprintf _vsnprintf
10. Repeat the nmake
command and this time it should succeed and you will end up with a tsql.exe
file.
C:\Users\marca\src\freetds-0.91>nmake ^ More? -fNmakefile -nologo apps ^ More? PLATFORM=win32 CONFIGURATION=debug ... C:\Users\marca\src\freetds-0.91>dir src\apps\win32\debug\tsql.exe Volume in drive C has no label. Volume Serial Number is D0C5-FA7C Directory of C:\Users\marca\src\freetds-0.91\src\apps\win32\debug 07/18/2013 04:19 PM 847,872 tsql.exe 1 File(s) 847,872 bytes 0 Dir(s) 19,728,400,384 bytes free
11. Give it a spin:
C:\Users\marca\src\freetds-0.91>src\apps\win32\debug\tsql ^ More? -H <server> -p 1433 ^ More? -U <username> -P <password> -D <database> ... 1> SELECT @@version 2> GO Microsoft SQL Server 2008 R2 (SP2) - 10.50.4279.0 (X64) Mar 26 2013 17:33:13 Copyright (c) Microsoft Corporation Developer Edition (64-bit) on Windows NT 6.1(Build 7601: Service Pack 1) (Hypervisor) (1 row affected)
A few useful links: