首页 文章

VS2010 C MFC多项目解决方案覆盖dll项目的自动链接

提问于
浏览
0

我有一个包含17个子项目的MFC解决方案 . 我刚刚添加了另一个dll项目,无法将可执行文件链接到库的重命名版本 . 在解决方案中的dll项目的设置中,调试版本都在输出名称后附加了一个“D”,表示它是调试版本 . 在某些情况下,我们通过将TargetName更改为$(ProjectName)D来执行此操作,而在其他情况下,post build事件将其从构建目录复制到lib目录并将其重命名为附加“D” . 对于这个项目,当我编译dll时,我得到了预期的两个文件:MultiLangD.lib和MultiLangD.dll . 这是dll项目的链接器命令行:

/OUT:".\Debug\MultiLangD.dll" /NOLOGO /DLL /MANIFEST 
/ManifestFile:".\Debug\MultiLangD.dll.intermediate.manifest" /ALLOWISOLATION 
/MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG 
/PDB:"C:\WorkSpaces\WorkSpace_CFFT_II_i18n\CFFT_i18n_MBCS\CFFT\MultiLang\Debug\MultiLangD.pdb" 
/PGD:"C:\WorkSpaces\WorkSpace_CFFT_II_i18n\CFFT_i18n_MBCS\CFFT\MultiLang\Debug\MultiLangD.pgd" 
/TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\Debug\MultiLangD.lib" /MACHINE:X86 
/ERRORREPORT:QUEUE

这是dll项目的编译器命令行:

/ZI /nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_AFXEXT" /D
"_MULTILANGDLL" /D "_CRT_SECURE_NO_WARNINGS" /D "_WINDLL" /D "_MBCS" /D "_AFXDLL" /Gm
/EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /GR- /Yu"StdAfx.h" 
/Fp".\Debug\MultiLangD.pch" /Fa".\Debug\" /Fo".\Debug\" /Fd".\Debug\vc100.pdb" /Gd 
/analyze- /errorReport:queue

在可执行项目中,我将MultiLangD.lib列为链接器的附加依赖项,将“链接库依赖项”设置为“否”,并将“使用库依赖项输入”设置为“是” . MultiLang DLL项目未设置为可执行文件的项目依赖项 . 然而,在调试版本中,我收到错误,因为链接器找不到MultiLang.lib . 这是可执行项目的链接器命令行:

/OUT:".\Debug\WinGFApp.exe" /INCREMENTAL /NOLOGO /LIBPATH:"..\Lib"
/LIBPATH:"..\Student\lib" /LIBPATH:"C:\Program Files (x86)\Microsoft DirectX SDK (March 2009)\Lib\x86" 
"MultiLangD.lib" "datastored.lib" "shlwapi.lib" "ws2_32.lib" "MdxReadd.lib" "winmm.lib" 
"dxguid.lib" "dxerr9.lib" "dinput8.lib" "Messagingd.lib" "dtccd.lib" "Version.lib" 
"SerialTCIMD.lib" "geosrvdll.lib" "NetworkUIDMD.lib" "amp2.lib" "idmmib.lib" 
"vmfr2.lib" "d3dx9.lib" "comsuppwd.lib" "vmf_net_db.lib" "jvmfd.lib" 
/NODEFAULTLIB:"libc" /NODEFAULTLIB:"libcd" /NODEFAULTLIB:"libci" /MANIFEST 
/ManifestFile:".\Debug\WinGFApp.exe.intermediate.manifest" /ALLOWISOLATION 
/MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:".\Debug/CFFTInstrD.pdb" 
/SUBSYSTEM:WINDOWS
 /PGD:"C:\WorkSpaces\WorkSpace_CFFT_II_i18n\CFFT_i18n_MBCS\CFFT\Instructor\Debug\WinGFApp.pg
d" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE

这是编译器命令行:

/I"." /I"..\Instructor\csw" /I"..\Instructor\CFFTInstr" /I"..\Student\common" 
/I"..\Student\Messaging" /I"..\Student\geotrans" /I"..\SerialTcim" /I"..\AudioServer" 
/I"..\NetworkUIDM\UIDM_Include" /I"..\NetworkUIDM\UIDM_JVMF" /I"..\NetworkUIDM" 
/I"..\Instructor\cas" /I"..\Jvmf" /I"..\Instructor\JvmfGui" /I"..\Instructor\JvmfCff" 
/I"..\NLOS" /I"C:\Program Files (x86)\Microsoft DirectX SDK (March 2009)\Include" /Zi 
/nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "NO_MSGS" /D 
"INSTRUCTOR" /D "_CRT_SECURE_NO_DEPRECATE" /D "_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES" 
/D "_CRT_NONSTDC_NO_DEPRECATE" /D "_VC80_UPGRADE=0x0600" /D "_MBCS" /Gm- /EHsc /RTC1 
/MTd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yu"stdafx.h" /Fp".\Debug/WinGFApp.pch" 
/Fa".\Debug/" /Fo".\Debug/" /Fd".\Debug/" /FR".\Debug\" /Gd /analyze-/errorReport:queue

当我在np中打开.vcxproj文件并搜索MultiLang.lib时,它只在发布版本中显示为依赖项,而在调试版本设置中列出了MultiLangD.lib . 这是.vcxproj文件中的调试设置ItemDefinitionGroup节点:

</ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
  <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  <MkTypLibCompatible>true</MkTypLibCompatible>
  <SuppressStartupBanner>true</SuppressStartupBanner>
  <TargetEnvironment>Win32</TargetEnvironment>
  <TypeLibraryName>.\Debug/WinGFApp.tlb</TypeLibraryName>
  <HeaderFileName>
  </HeaderFileName>
</Midl>
<ClCompile>
  <Optimization>Disabled</Optimization>
  <AdditionalIncludeDirectories>.;..\Instructor\csw;..\Instructor\CFFTInstr;..\Student\common;..\Student\Messaging;..\Student\geotrans;..\SerialTcim;..\AudioServer;..\NetworkUIDM\UIDM_Include;..\NetworkUIDM\UIDM_JVMF;..\NetworkUIDM;..\Instructor\cas;..\Jvmf;..\Instructor\JvmfGui;..\Instructor\JvmfCff;..\NLOS;C:\Program Files %28x86%29\Microsoft DirectX SDK %28March 2009%29\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;NO_MSGS;INSTRUCTOR;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
  <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  <PrecompiledHeader>Use</PrecompiledHeader>
  <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
  <PrecompiledHeaderOutputFile>.\Debug/WinGFApp.pch</PrecompiledHeaderOutputFile>
  <AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
  <ObjectFileName>.\Debug/</ObjectFileName>
  <ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
  <BrowseInformation>true</BrowseInformation>
  <WarningLevel>Level3</WarningLevel>
  <SuppressStartupBanner>true</SuppressStartupBanner>
  <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
  <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  <Culture>0x0409</Culture>
</ResourceCompile>
<Link>
  <AdditionalDependencies>MultiLangD.lib;datastored.lib;shlwapi.lib;ws2_32.lib;MdxReadd.lib;winmm.lib;dxguid.lib;dxerr9.lib;dinput8.lib;Messagingd.lib;dtccd.lib;Version.lib;SerialTCIMD.lib;geosrvdll.lib;NetworkUIDMD.lib;amp2.lib;idmmib.lib;vmfr2.lib;d3dx9.lib;comsuppwd.lib;vmf_net_db.lib;jvmfd.lib;%(AdditionalDependencies)</AdditionalDependencies>
  <SuppressStartupBanner>true</SuppressStartupBanner>
  <AdditionalLibraryDirectories>..\Lib;..\Student\lib;C:\Program Files %28x86%29\Microsoft DirectX SDK %28March 2009%29\Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
  <IgnoreSpecificDefaultLibraries>libc;libcd;libci;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
  <GenerateDebugInformation>true</GenerateDebugInformation>
  <ProgramDatabaseFile>.\Debug/CFFTInstrD.pdb</ProgramDatabaseFile>
  <SubSystem>Windows</SubSystem>
  <TargetMachine>MachineX86</TargetMachine>
</Link>
<Bscmake>
  <SuppressStartupBanner>true</SuppressStartupBanner>
  <OutputFile>Debug/CFFTInstrD.bsc</OutputFile>
</Bscmake>
<PostBuildEvent>
  <Message>Copy Executable</Message>
  <Command>if not exist ..\exec mkdir ..\exec
    copy debug\WinGFApp.exe ..\exec\CFFTInstrD.exe
  </Command>
</PostBuildEvent>
<ProjectReference />
<ProjectReference>
  <UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
  <LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>

不幸的是,生成的所有可执行文件和dll都作为post build事件被复制到单个目录中,因此我必须遵循“append D”命名约定以避免覆盖其他构建的工件 . 我不确定为什么构建中的其他dll项目都没有这个问题 . 我显然在这里遗漏了一些东西,但无法弄清楚它是什么 . 有人可以告诉我我做错了什么以及如何做到这一点 . 谢谢 .

EDIT 我忘了提到我还尝试在Common Properties-> Framework and References中添加对项目的引用 .

Reference settings

此外,在编译过程中,我看到 Automatically linking with MultiLang.lib 滚动 .

1 回答

  • 0

    好的,我搞定了 . 我删除了引用并将Linker-> General-> Ignore Import Library设置为Yes . 我把其他所有内容保持不变,现在它编译并链接就好了 .

相关问题