简体   繁体   English

VS6.0中的LNK2019错误-> VS2013迁移的MFC DLL项目

[英]LNK2019 error in VS6.0 -> VS2013 migrated MFC DLL project

I get the following link error when attempting to build/port a LARGE VS6.0 DLL project to VS2013 where DLL modules are dependent on other DLL modules. 尝试将大型VS6.0 DLL项目构建/移植到VS2013时,出现以下链接错误,其中DLL模块依赖于其他DLL模块。 The unique thing about the undefined function is that it takes CString arguments, but perhaps the problem is more obvious than that: 未定义函数的独特之处在于它带有CString参数,但问题可能比这更明显:

error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall CTokenEx::Split(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >,class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >,class CStringArray &,int)" (__imp_?Split@CTokenEx@@QAEXV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@0AAVCStringArray@@H@Z) referenced in function "public: bool __thiscall OptionFlag::isTestEnableByFlag(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >)" (?isTestEnableByFlag@OptionFlag@@QAE_NV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z)

Here is the dumpbin.exe for this module where the symbol is exported (from the *.exp file): 这是此模块(从* .exp文件中)导出符号的模块的dumpbin.exe:

 00000148  DIR32NB                    00000000        20  $N00027
 00000094  DIR32NB                    00000000        4F  ?Split@CTokenEx@@QAEXV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@0AAVCStringArray@@H@Z (public: void __thiscall CTokenEx::Split(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >,class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >,class CStringArray &,int))
 0000014C  DIR32NB                    00000000        21  $N00028

Here is the dump from the *.lib file and I see __imp_ in the *.lib file. 这是* .lib文件的转储,我在* .lib文件中看到__imp_。

     3E30 ?Split@CTokenEx@@QAEXV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@0AAVCStringArray@@H@Z
     3E30 __imp_?Split@CTokenEx@@QAEXV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@0AAVCStringArray@@H@Z

Of course I need to triple check again that I'm reading this exact .exp/ .lib which is what /Verbose tells me. 当然,我需要再次三倍检查我读这个确切.EXP / .LIB这是什么功能/ verbose告诉我。

In this particular case, all the issue(s) I have are cases where DLL "x" references a function in DLL "y" which has a CTokenEx::Split() function which has CString arguments. 在此特定情况下,我遇到的所有问题都是DLL“ x”引用DLL“ y”中具有CTokenEx :: Split()函数且具有CString参数的函数的情况。 I thought that the problem was the CSTring MFC vs ATL declaration (see links below), now I'm not so sure, so am going back to square one after posting this here. 我以为问题是CSTring MFC vs ATL声明(请参见下面的链接),现在我不太确定,因此在此发布后回到第一点。 (ie is it a typo I missed? DOH?) (即我错过了错字吗?DOH?)

I've done the following to isolate the problem Build properties: 我已完成以下操作以隔离问题Build属性:

  1. Verified all modules are using MBCS (Multi Byte Char Set) not Unicode 验证所有模块都使用MBCS(多字节字符集)而不是Unicode
  2. Verified all modules are building with "Using MFC in a DLL" 验证所有模块是否都在使用“在DLL中使用MFC”构建
  3. Run the linker with /Verbose and Verbose:lib to verify the linker was referencing the linked file I expected. 使用/ Verbose和Verbose:lib运行链接器,以验证链接器正在引用我期望的链接文件。
  4. Used dumpbin.exe to examine the exported symbol decorations to see if they are getting exported. 使用dumpbin.exe检查导出的符号装饰,以查看它们是否正在导出。 (I think they are, but I'm not a dumpbin expert). (我认为是的,但我不是垃圾桶专家)。
  5. Found these possibly related links: 找到了这些可能相关的链接:
    MSDN LNK2019 error and attempted to hardcode the dllimport of the CString type. MSDN LNK2019错误,并尝试对CString类型的dllimport进行硬编码。
    link with respect to MFC and CRT CSTring definitions. 有关 MFC和CRT CSTring定义的链接。 Not 100% sure this is the issue. 并非100%确定这是问题所在。 (could be something I'm missing in the arguments.) (可能是我在参数中缺少的东西。)
  6. included "afxstr.h", and forced -D"_MFC_DLL_BLD" 包括“ afxstr.h”和强制-D“ _MFC_DLL_BLD”

The CTokenEx portion of the DLL module I'm working with appears to be from here but I haven't confirmed it. 我正在使用的DLL模块的CTokenEx部分似乎来自此处,但我尚未确认。 At the moment, I'm not sure that is relevant. 目前,我不确定是否相关。

I'm just looking for confirmation that my analysis of dumpbin.exe which tells me the symbols are exported correct is accurate. 我只是想确认我对dumpbin.exe的分析是否正确,该分析告诉我符号正确输出。 I thought it could be a link-order issue, and referenced the DLL a second time to the linker, but that didn't help. 我认为这可能是链接顺序问题,并且第二次将DLL引用到链接器,但这没有帮助。 In a past life that worked in similar linker issues in SunOs (back in ancient times). 在过去的生活中,SunOs曾在类似的链接器问题中工作(追溯到远古)。

If I figure this one out, I will post an answer to this problem. 如果我解决了这个问题,我将发布此问题的答案。

!DOH! !DOH! After you have eliminated all other options. 消除所有其他选项之后。 . Although using /Verbose and /Verbose:lib show you where the *.lib files are, and confirms they are found, you must pay attention! 尽管使用/ Verbose和/ Verbose:lib会向您显示* .lib文件的位置,并确认已找到它们,但您必须注意! In my case, there were some VS6.0 STALE *.lib files in "." 就我而言,“。”中有一些VS6.0 STALE * .lib文件。 relative to the solution workspace and the linker found those first, and of course they likely didn't have the symbols properly decorated. 相对于解决方案工作区,链接器首先找到了那些,当然,它们可能没有正确装饰符号。 If the linker tells you that it linked in: 如果链接器告诉您它已链接:
mylib.lib instead of mylib.lib而不是
path\\to\\Mylib.lib it's a major clue :). path \\ to \\ Mylib.lib这是一个主要线索:)。

Sooo... what I thought was a complex & strange linker problem. 太...我以为是一个复杂而奇怪的链接器问题。 Was a !DOH! 是!DOH! easy linker problem. 简单的链接器问题。

Problem solved, just that simple. 问题解决了,就这么简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM