2013-02-26 55 views
0

我有一个包含17个子项目的MFC解决方案。我刚刚添加了另一个dll项目,无法将可执行文件链接到库的重命名版本。在解决方案中的dll项目的设置中,调试版本都在输出名称后附加了'D'来表示它是调试版本。在某些情况下,我们通过将TargetName更改为$(ProjectName)D来实现此目的,而在其他情况下,后构建事件会将其从构建目录复制到lib目录,并将其重命名为附加'D'。对于这个项目,当我编译DLL时,我得到两个文件:MultiLangD.lib和MultiLangD.dll。这是dll项目链接器命令行:VS2010 C++ MFC多项目溶出覆盖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> 

不幸的是,产生被复制到一个目录后生成事件,所以我必须要遵循“追加d”命名的所有可执行文件和DLL约定来避免覆盖其他版本的工件。我不确定为什么没有其他的项目在构建中有这个问题。我明显错过了一些东西,但无法弄清楚它是什么。有人能告诉我我做错了什么,以及如何做到这一点。谢谢。

编辑 我忘了提及我也尝试在Common Properties-> Framework and References中添加对项目的引用。

Reference settings

此外,虽然编制正在进行中我看到Automatically linking with MultiLang.lib滚动通过。

回答

0

好的,我明白了。我删除了引用,并将链接器 - >常规 - >忽略导入库设置为是。我把所有的东西都留下了,现在编译和链接就好了。