处理 __turboFloat 和 Borland 工具链

Dealing with __turboFloat and the Borland toolchain

我一直在尝试恢复一个 XP 时代的 .dll,它使用 Microsoft 的 Uniscribe、可能的 VCL 和其他工件来进行一些音译。它当时是用一些 Borland 工具链编译的,我收到的项目包括来自 Visual Studio 的 .res 文件、.mrt 和 .mbt 文件,这些文件似乎也与 GUI 相关,.ide 文件是 Borland C++ 项目文件、.dsw Turbo C 上下文文件(在文本编辑器中打开它们——它们也可能是 VC6 文件……不寒而栗)、.bpr BCB.04.04 / BCB IDE 文件、.dfm 字体-相关文件和 .bpg BWS.01 文件。我觉得自己像数字印第安纳琼斯,没有鞭子和灰尘让我打喷嚏。

我从 Embarcadero 获得了一个 Borland 工具链并使用了 Code::Blocks,只有 -Weverything 行中的某个地方进入了编译器参数,Borland 不喜欢这样。 LLVM 的 Clang 目前在 winnt.h(我宁愿不编辑)和

之类的东西上呕吐
\um\winnt.h:1341:1: error: C++ requires a type specifier for all declarations

Visual Studio 的编译器完全吐在其他东西上(虽然没太在意它)而且我不记得 MinGW/GCC 在哪里停止了。

我不得不 fiddle 包含和库(主要来自 Embarcadero 的包含\和库)和编译器标志(当前 _NO_VCL _MSC_VER=1200 BUILD_DLL) 由于一堆或不同的错误,甚至不会理会警告。使用 cmd 行编译这个项目(使用 .bpr 文件之一和 Embarcadero 的 documentation 作为参考)我设法用这个编译了一个 .obj:

"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

是的。当我尝试 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"

我得到:

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

Googlefu 告诉我这是某种 Borland 供应商锁定的事情,所以我将 link 行更改为:

"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"

...现在它真的很受欢迎:

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

我有点不知所措。任何提示将不胜感激。

根据 forums and a 11 years old post 的一些指示,我向 link 行添加了一些额外的 .obj,即 cw32mt.libimport32.lib,因此最后一行看起来像像这样 (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",,

一行,有一些,,并且没有空格。 Code::Blocks 也很方便。