- Published on
Borland C++ Builder: Error invalid OMF record, type 0x021
- Authors

- Name
- Daisuke Kobayashi
- https://twitter.com
Today a customer reported that the SDK we provide could not be linked from Borland C++ Builder. I only learned this after investigating, but apparently Borland C++ Builder cannot link libraries created with Visual C++ as-is. If you try to link them directly, you get an error like the following.
bcc32 main.cpp win.lib -o main Error: 'C:\USERS\DAISUKE\HOME\WIN.LIB' contains invalid OMF record, type 0x21 (possibly COFF)
In the end, I was able to link it by converting the import library file for the Visual C++ library (lib, dll) with Borland's standard tool coff2omf. I am summarizing the verification steps below.
Installation
Follow the instructions on this page to obtain the free C++ compiler. Enter the required information and download the free edition. The downloaded archive requires a password to extract, and that password is sent to the email address you registered.
After extracting the archive, you will get freecommandlinetools2.exe and freeturbodebugger.exe. This time I only needed the compiler, so I installed freecommandlinetools2.exe. I used the default installation path, C:\borland.
Next, configure the include and library directories. Create a file named bcc32.cfg under C:\borland\bcc55\Bin, add the lines below, and save it.
-IC:\borland\bcc55\Include -LC:\borland\bcc55\Lib
Finally, add C:\borland\bcc55\Bin to your PATH. Once that is done, you should be able to compile from the command line with bcc32.
Converting the library
Use coff2omf.exe to convert the library into a format that Borland can import.
coff2omf.exe win.lib win_borland.lib
Then link against the converted library and verify that it works.
bcc32.exe main.cpp win_borland.lib -o main ./main