x86dos - SQL Server - DB-Library SDK for MS SQL Server

Workarund for link errors occur when DB-Library 6.5 SDK is linked with Borland C++ 4.52.

Comments

Abstract

There are two link errors that prevent the original DB-Library 6.5 SDK from being linked with Borland C++ 4.52 successfully as seen in the following screenshot:

People posted about the same issues on internet many years ago but still get no answers or fixes so far. And Microsoft has never fixed the issues as it disconnected DB-Library for DOS after SQL Server 6.5. I thought the fixes would not be so complicate once the causes found, so I decided to find a way to compile DB-Library application with Borland C++ 4.52 by myself. After some try and error, I came up with the workarounds for the two errors in 2005. I give more details below. Though now these workarounds may be not helpful to people sought the fixes 10 years ago as they had long moved on to Windows.

Requirements:

1. DOS (pure DOS, DosBox with SQL Server support or 32 bit Windows DOS VM etc.)

Here you can find a copy of my build of DosBox (with SQL Server support):
DOS/DosBox advanced tools

2. DB-Library SDK from Microsoft SQL Server 6.X.
You can get Microsoft SQL Server 6.X on Vetusware and extract DB-Library SDK out of it. Some minor changes to .h files and workarounds for link errors are required for it to be usable in Borland C++ 4.52; so I suggest you download the fixed DB-Library SDK from the following local link: DB-Library SDK, then unpack the downloaded zip file to a folder (let it be '\dev\sdks\sqlsdk') and set the include and lib environment variables as follows:
    set path=%path%;\tools\sqltools;\dev\sdks\sqlsdk
    set include=%include%;\DEV\SDKS\sqlsdk
    set lib=%lib%;\dev\sdks\sqlsdk
3. DB-Library TSRs from Microsoft SQL Server 6.X.
You can find Microsoft SQL Server 6.X on Vetusware and extract DB-Library TSRs out of it. Or you can download DB-Library TSRs from the local link:DB-Library TSRs.
Then unpack the downloaded zip to a folder (let it be '\tools\sqltools') and set the path environment variable as follows:
    set path=%path%;\tools\sqltools;\dev\sdks\sqlsdk
    set include=%include%;\DEV\SDKS\sqlsdk
    set lib=%lib%;\dev\sdks\sqlsdk
4. A Microsoft SQL Server instance (Anything from SQL 4.2 up to SQL 2016).
5. Classic Pubs Sample database.
Local download link:Pubs Sample database.
After the Pubs database downloaded, unpack it to a folder, then attach it to the above SQL Server instance and set up permissions correctly. Also make sure that Named-pipe protocol is enabled on SQL Server.
6. Borland C++ 4.52 which you can get from Vetusware too.

Link error 1 - "Undefined symbol GETNODE in bldblib in module DBEXTERN."

Because DB-Library 6.5 SDK was built with an early version of Borland C++ (3.1 I suppose), some symbols it references are not present in Borland C++ 4.52 and GETNODE is one of them.

Workaround

Here my solution is creating an empty function put in an assembly code file getnode.asm for the missing symbol as follows:
;The dummy function is for getting rid of link error "Undefined symbol GETNODE......" in Borland C++ 4.52
.model large
.code
	public	GETNODE
GETNODE	proc	FAR
	retf
GETNODE	endp
end
As GETNODE is not actually used by DB_library, an empty funciton is enought to slient tlink.exe.

Link error 2 - "Undefined symbol _sys_errlist in bldblib in module DBERROR."

The cause of this error is that the real _sys_errlist is overridden by symbol sys_errlist that defined in and they are not the same.

Workaround

Here my solution is to un-define sys_errlist that defined in and reassign the real _sys_errlist to symbol sys_errlist. To use the workaround, put the following lines at the beginning of your source file:
#ifdef __BORLANDC__
    #include 
    #undef sys_errlist		/*Workaround for link error "undefined _sys_errlist..."*/
    char**	sys_errlist=_sys_errlist;
#endif

Example

You can check a complete example in file EXAMPLE1.C. To build EXAMPLE1.C, you can use buildbor.bat included with the download package of DB-Library 6.5 SDK (Fixed for Borland C++ 4.52).

        buildbor.bat example1.c
The original BUILDBOR.MAK invoked buildbor.bat has been modified to include getnode.asm, so you don't have to include it in the above command line.

Download links

(2k16.2.6)