When using external libraries (with .lib files) and are getting linker errors like below, you are using an imcompatible import library (.lib) file.
Invalid OMF record type 0x21 (possibly COFF)
The reason for this is that your import library file was designed for MSVC. The one uses the COFF format, which is not compatible with Borland's OMF format.
To solve this, try the following and in preferred order:
Try obtaining the Borland compatible version of the import library. While difficult, this will always work.
Use the conversion tools in Borland. Read Convert MSVC import libraries for use in Borland C Builder for more info on these tools.
By default, import libraries (.lib files) made for MSVC are not compatible with Borland C Builder and Borland Delphi. Since version 6 of Borland C++ Builder, there's a tool which can convert these files in COFF format to OMF format. The tool is called coff2omf and resides in the Bin directory of your Borland installation.
Simply run the file as follows (be sure your path etc. is correct):
coff2omf mylib.lib mylib2.lib
Then, use the mylib2.lib file you just created and add it to your project.
Notice
The coff2omf tool only works properly if the library exports plain C functions. If C++ classes or mangled function names get exported, you usually get linker errors. If this is th ...