简体   繁体   English

将DLL与C ++项目中的其他输出文件分开

[英]Separate dll from other output files in c++ projects

I have a few dll projects in a solution (some depending on each other) 我在解决方案中有几个dll项目(彼此依赖)

Project1 -> Properties -> Linker -> Input -> Additional Dependencies -> Project2.lib
Project1 -> Properties -> Linker -> General -> Additional Library Directories -> $(OutDir)

All is working fine. 一切正常。

Projects are Win7Debug Win32, Win7Debug x64..... and a Win32 project with only Debug and Release configurations. 项目是Win7Debug Win32,Win7Debug x64 .....和仅具有Debug和Release配置的Win32项目。

I would like to have all dll's for Win32 placed in one folder and the x64 ones in another folder. 我想将Win32的所有dll放在一个文件夹中,而x64的dll放在另一个文件夹中。 So I added the x64 configuration for the Win32 project, and changed 所以我为Win32项目添加了x64配置,并进行了更改

Project1 -> Properties -> Linker -> General -> Output File -> $(SolutionDir)/i386/$(TargetName)/$(TargetExt)

(for Win32 - similar change for x64) (对于Win32-对于x64的类似更改)

all seemed fine - and I only received dlls in the i386 folder... until I had to rebuild and got 一切似乎都很好-我只在i386文件夹中收到dll ...直到我不得不重建并得到

Warning 23  warning MSB8012: 
TargetPath(C:\Path\Win7Debug\Project1.dll) does not match the Linker's OutputFile 
property value (C:\Path\i386\Project1.dll). This may cause your project to build 
incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and 
$(TargetExt) property values match the value specified in %(Link.OutputFile).   

This seems serious... and I don't want to have problems with missing dependencies (though everything seems to be working fine - and not just on my machine) 这似乎很严重...而且我不想因缺少依赖项而遇到问题(尽管一切似乎都可以正常工作,而不仅仅是在我的机器上)

I changed 我变了

 Project1 -> Properties -> Configuration Properties -> General -> OutputDirectory -> $(SolutionDir)/i386

(to match the linker output) but now of course I get lib and exp files in the same folder as the dll's. (以匹配链接器的输出),但是现在我当然将lib和exp文件与dll放在同一文件夹中。

Other than using post build script, is there a way to separate the output files ? 除了使用后期生成脚本之外,还有没有其他方法可以分隔输出文件?

Should I just leave the settings how I had them and disregard the warning above ? 我应该只保留设置的方式而忽略上面的警告吗?

Note : I am not trying to separate the Platform/configuration output files... That is done automagically using the default output directory. 注意 :我不是要分隔平台/配置输出文件...这是使用默认输出目录自动完成的。

What I need is, for each platform, to place only DLL files in one folder away from anything else. 对于每个平台,我需要的是将DLL文件仅放置在一个文件夹中,且与其他任何文件都不要。 Redirecting Linker output (and leaving project output to standard) accomplishes that - I just am not sure if it is correct. 重定向链接器输出(并将项目输出保留为标准输出)可以达到目的-我只是不确定它是否正确。 Logically I should not have any build problems since I am giving linker all the info it needs... 从逻辑上讲,我不应该有任何构建问题,因为我为链接器提供了所需的所有信息...

The standard approach is to leave all these properties unchanged (inherit from parent). 标准方法是保留所有这些属性不变(从父级继承)。 In this case linker will create DLL and LIB in $(Output) directory, which by default is $(SolutionDir)$(Configuration) . 在这种情况下,链接器将在$(Output)目录中创建DLL和LIB,默认情况下为$(SolutionDir)$(Configuration) You just specify the name for x64 configuration, and all output files will be separated automatically. 您只需为x64配置指定名称,所有输出文件将自动分离。

The standard (and the easest) way to link import library is to add reference to corresponding project in Common Properties / References page. 链接导入库的标准方法(也是最简便的方法)是在“ Common Properties / References页面中为相应的项目添加引用。 Nothing else is required. 没有其他要求。

If, for any reason, it is impossible, add $(SolutionDir)$(Configuration) to Configuration Properties / VC++ Directories / Library Directories and add library to be linked to Linker / Additional Dependencies . 如果由于某种原因是不可能的,则将$(SolutionDir)$(Configuration)Configuration Properties / VC++ Directories / Library Directories并添加要链接到Linker / Additional Dependencies项的库。 If there are many projects in your solution, you may create Property Sheet for the solution and specify Library Directories only once. 如果您的解决方案中有很多项目,则可以为该解决方案创建属性表,并仅指定一次Library Directories

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

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