繁体   English   中英

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

[英]VS2010 C++ MFC Multiple project solution override automatic linking of dll project

我有17个子项目的MFC解决方案。 我刚刚添加了另一个dll项目,但无法获取可执行文件以链接到该库的重命名版本。 在解决方案中dll项目的设置中,所有调试版本都在输出名称后附加了一个“ D”,以表示它是调试版本。 在某些情况下,我们通过将TargetName更改为$(ProjectName)D来完成此操作,在其他情况下,构建后事件会将其从构建目录复制到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列为链接器的附加依赖项,将“链接库依赖项”设置为no,将“使用库依赖项输入”设置为yes。 该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作为生成后的事件都复制到一个目录中,因此我必须遵循“ append D”命名约定,以避免覆盖其他生成的工件。 我不确定为什么构建中的所有其他dll项目都没有此问题。 我显然失去了一些东西在这里,但无法弄清楚它是什么。 有人可以启发我做错什么以及如何做到这一点。 谢谢。

编辑我忘了提,我也试图增加在公共属性- >框架和参考的项目的引用。

参考设定

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

好吧,我知道了。 我删除了引用,并将“链接器”->“常规”->“忽略导入库”设置为“是”。 我将其他所有内容都保留了下来,现在可以正常编译和链接了。

暂无
暂无

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

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