• Please review our updated Terms and Rules here

How to make Borland C++ 5.02 compile 16-bit programs on an x64 system...

alank2

Veteran Member
Joined
Aug 3, 2016
Messages
2,396
Location
USA
Hi Everyone,

I've developed with Borland C++ 5.02 for years, but one thing that is annoying is that the DOS linker (TLINK.EXE) was never updated to 32-bit. The result is that it compiles DOS applications with a 32-bit tool, and then links them with a 16-bit tool. This wasn't a problem at the time, but when 64-bit operating systems dropped support for running 16-bit code, it means that you can compile a DOS application on x64, but you can't link it.

Obviously the best solution would be a 32-bit version of TLINK.EXE, but after some searching for tools or something that might be able to convert a DOS application to a Win32 console application, I didn't find anything that could do something like this. If you could disassemble it and port it to win32 and recompile it that would be a great solution, but I would imagine a huge undertaking if possible at all.

I also read about someone who was trying to bring 16-bit NTVDM support to x64 systems, but it sounds like quite a bit of work to accomplish and talked about making OS changes that didn't sound comforting.

I was wondering about DOSBox or something similar, but in this case the BC5 IDE calls TLINK.EXE and expects an errorlevel returned. I found a tool called VDOS that is a single executable that starts up and autoruns an AUTOEXEC.TXT file. With this in mind I made a "stub" or placeholder for TLINK.EXE which is a 32-bit console application. It can be launched from the BC5 IDE and its job is to be the "go between". It will setup the AUTOEXEC.TXT file and launch VDOS.EXE to which calls TLINKDOS.EXE to carry out the link, and then finally it will return the errorlevel to the BC5 IDE.

The linking problem probably isn't the only problem - you also can't install BC5 on x64 because it uses a 16-bit installer, but Borland has the whole BC5 directory on the CD-ROM and you can just copy it. You could also install it on x86 and then copy the directory from that to your x64 machine. You also can't debug or run 16-bit code unless you launch VDOS and run it or debug it there.

It might work with older Borland windows based compilers as well, I'm not sure because I haven't tested it.

To make this work:

Rename the real TLINK.EXE file in the BC5\BIN directory to TLINKDOS.EXE.

Copy the TLINK.EXE file from the attached ZIP file into the BC5\BIN directory.

Obtain the VDOS.EXE from this location and also put it in the BC5\BIN directory:
http://www.vdos.info

I've include my TLINK.CPP so you can tweak it if necessary. It will automatically detect the BC5 installation path. It goes without saying that the BC5 installation path and project path should be short file name compatible.
 

Attachments

I've got plenty of machines I can run it on...it was an exercise to see if I could make it work!
 
Odd that DOSBox would give you an error... how about a proper virtual machine? Install something like 32 bit XP in Oracle VirtualBox where you can still run 16 bit DOS stuff in the shell window, but is new enough that the client software lets you map network shares and/or drag/drop between desktops.

Would be WAY faster than DOSBox being that it's a Virtual Machine, so things would run WAY closer to native speed.
 
An update on this - I found a really cool tool here called the MS-DOS Player that does this much easier than using vDOS:


This program has a way to make a new executable to replace the old.

To do this just do this:

cd\bc5\bin
ren tlink.exe tlinkdos.exe
msdos -ctlink.exe tlinkdos.exe

The msdos.exe (MS-DOS Player) will create a new tlink.exe that acts and feels just like its dos counterpart.
 
Yes, MS pushed out 16 bit compatibility when they pushed everyone towards 64-bix operating systems.
 
An update on this - I found a really cool tool here called the MS-DOS Player that does this much easier than using vDOS:


This program has a way to make a new executable to replace the old.

To do this just do this:

cd\bc5\bin
ren tlink.exe tlinkdos.exe
msdos -ctlink.exe tlinkdos.exe

The msdos.exe (MS-DOS Player) will create a new tlink.exe that acts and feels just like its dos counterpart.
Alank2, How do I do this? I gotta say I LOVED BC5 in its time (and much else old stuff vs. hate for some newer tools) and now need to mod some of my old code to run on old machines -- so I pulled out the disk and was able to get it to install.

I'm using Windows 11 and could venture into the C:BC5 directory and rename tlink.exe to tlinkdos.exe. But what is that next step with "msdos", do I do that in powershell or? And how will I tie it to the IDE which will compile my old project in its old IDE but is complaining: "Transferring to C:\BC5\BIN\tlink.exe @C:\Users blah blah con_comp.r$p / Could not load: tlink.exe

I'd like to get the IDE working again; thanks for any help you can lend on this,

~~ Robert
 
You can't install BC5 on windows 11 using its installer because it is a 16-bit installer. You have to install BC5 on a compatible system such as a 32-bit OS in a VM, etc. Once you have it installed, then copy the C:\BC5 folder over to your WIndows 11 system. MOST of BC5 is 32-bit and will run on Win11 if you start BCW.EXE. The problem comes in when you try to link a dos program because it then invokes the TLINK.EXE which is 16 bit and will not run on Win11. That is why you have to use the msdos.exe program above to convert it to a 32-bit application that will run. Good luck!
 
I run MSC (16 bit) under WinXP on Virtualbox on 64-bit Debian Linux. Probably a similar situation applies for Windows 11 and other such atrocities.
 
Thanks very much, everyone! Since I don't know how to use the msdos.exe program to convert it (or where that is / how to get it) I will try to get DOS box and start over with an install of the BC5 disk. The target output is a DOS application, by the way. I think people may not know that DOS was a very good real time OS -- just a foreground and interrupt routine is all I needed, anyway, to accomplish good things a while back. I tried to get QNX to relent on their pricing in that same time frame, but nope -- so I chose DOS and was very happy with it.
 
Thanks! I was able to get "DOS Box X" running on this machine. It seems to be an OK DOS emulator, though not pleasant to use since I can't figure out to resize it from its gigantic 2/3 of my gigantic monitor -- the letters are like 1" tall each. But hey. This takes care of me at the moment. Thanks for everyone's comments and help!
 
Back
Top