This question was migrated from Software Engineering Stack Exchange because it can be answered on Stack Overflow. Migrated四年前Learn more
我一直在试图压缩一个XP era.dll,它使用微软的Uniscribe,prossible VCL和其他工件来做一些音译它是在一些Borland toolchain的时候编译的,我提交的项目包含了来自VisualStudio、MRT和MBT文件的文件,这些文件似乎也是与GUI相关的,IDE文件是Borland C++项目文件…shuders),.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在哪里停止了。
由于一堆或不同的错误,我不得不修改include和lib(主要是来自Embarcadero的include和lib)以及编译器标志(当前的_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供应商锁定的东西,所以我将链接行改为:
"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\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

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

最佳答案

forums11 years old post中的一些指针之后,我在链接行中添加了一些额外的.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",,

它是一条单行,有些,,没有空格Blocks也很方便。

10-07 18:53