Search code examples
cc++builderborland-c++

Dealing with __turboFloat and the Borland toolchain


I've been trying to ressurect a XP-era .dll that uses Microsoft's Uniscribe, prossible VCL and other artifacts to do some transliteration. It was compiled at the time with some Borland toolchain and the project i was handed includes .res files from Visual Studio, .mrt and .mbt files which also seem to be GUI-related, .ide files which are Borland C++ Project files, .dsw Turbo C Context files (opening 'em in a text editor - they could also be VC6 files... shuders), .bpr BCB.04.04 / BCB IDE files, .dfm font-related files and .bpg BWS.01 files. I feel like a digital Indiana Jones, minus the whip and dust makes me sneeze.

I got a Borland toolchain from Embarcadero and was using Code::Blocks, only somewhere among the line -Weverything gets into the compiler arguments, which the Borland doesn't like. LLVM's Clang currently barfs on winnt.h (which i'd rather not edit), on stuff like

\um\winnt.h:1341:1: error: C++ requires a type specifier for all declarations

Visual Studio's compiler barfs on something else entirely (didn't bother with it much, though) and i don't remember where did MinGW/GCC stop.

I've had to fiddle with includes and libs (mostly the ones from Embarcadero's include\ and lib) and compiler flags (currently _NO_VCL _MSC_VER=1200 BUILD_DLL) on account of a bunch or different errors and won't even bother with the warnings. Using the cmd line to compile this project (with one of the .bpr files and Embarcadero's documentation as reference) i managed to compile an .obj with this:

"C:\path\to\bcc32.exe" -w -tWM -tWD -y -vi- -v -a8 -r- -Od -D_NO_VCL -D_MSC_VER=1200 
    -I"C:\path\to\include\windows\crtl" 
    -I"C:\path\to\include\windows\vcl" 
    -I"C:\path\to\include\windows\rtl" 
    -I"C:\path\to\baseProjectDir" 
    -I"C:\path\to\baseProjectDir\subDir" 
    -oobj\Debug\myFile.obj -c ..\file1.cpp ..\subDir\file2.cpp ..\subDir\file3.cpp ..\subDir\file4.cpp

Yay. The fun continues when i try linking:

"C:\path\to\ILINK32.EXE" /aa /Tpd /x /Gn /Gi /q 
    /L"C:\path\to\baseProjectDir;C:\path\to\baseProjectDir\subDir;C:\path\to\lib\win32\debug;C:\path\to\lib\win32\release" 
    "C:\path\to\myFile.obj"

i get:

Error: Unresolved external '__turboFloat' referenced from root
Error: Unable to perform link

Googlefu tells me this is some sort of Borland vendor lock-in thing, so i changed my link line to:

"C:\path\to\ILINK32.EXE" /aa /Tpd /x /Gn /Gi /q 
    /L"C:\path\to\baseProjectDir;C:\path\to\baseProjectDir\subDir;C:\path\to\lib\win32\debug;C:\path\to\lib\win32\release" 
    "C:\path\to\lib\win32\release\c0d32.obj" "C:\path\to\myFile.obj"

...and now it really hits the fan:

Error: Unresolved external '__dbk_fcall_wrapper' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external 'GetVersion' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__ErrorMessage' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_DLL_Lock' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_VCL_Init' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_MEM_UseBorMM' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_VCLLIB_Linkage' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__ExceptInit' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__pRawDllMain' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__startupd' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__free_heaps' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_VCL_Exit' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_DLL_Unlock' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__GetExceptDLLinfoInternal' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external 'HeapAlloc' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_TLS_SetValue' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_TLS_InitThread' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external 'GetProcessHeap' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external 'HeapFree' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_TLS_ExitThread' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_TLS_Free' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_TLS_Alloc' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external 'DllEntryPoint' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__argv_expand_ptr' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__wargv_expand_ptr' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__handle_setargv' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__handle_exitargv' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__handle_wsetargv' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__handle_wexitargv' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__fileinfo' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '___CRTL_TLS_GetValue' referenced from C:\PROGRAM FILES (X86)\EMBARCADERO\STUDIO\17.0\LIB\WIN32\RELEASE\C0D32.OBJ
Error: Unresolved external '__turboFloat' referenced from root
Error: Unable to perform link

I'm kind of at a loss here. Any hints would be much appreciated.


Solution

  • After some pointers from the forums and a 11 years old post i added some extra .obj to the link line, namely cw32mt.lib and import32.lib, so that the final line looks something like this (YMMV):

    ilink32.exe -q 
    -L"C:\path\to\lib\win32c\debug" 
    -L"C:\path\to\lib\win32\debug" 
    -LC:\MinGW\lib 
    -LC:\path\to\myProject 
    -Tpd /DEBUG 
    obj\Debug\subDir\file1.obj
    obj\Debug\subDir\file2.obj,
    bin\Debug\final.dll,,C:\path\to\myProject\some.lib 
    "C:\path\to\lib\win32c\debug\cw32mti.lib" 
    "C:\path\to\lib\win32c\debug\import32.lib",,
    

    It is one single line, with some ,, and no spaces. Code::Blocks was handy too.