DLL项目无法建立,因为Linker无法找到相同的命名.lib文件 [英] Dll project doesn't build as Linker not able to find the same named .lib file

查看:99
本文介绍了DLL项目无法建立,因为Linker无法找到相同的命名.lib文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Visual Studio 2010环境中的新手.我有一个使用Visual Studio 2008开发的源库.我正在尝试在VS 2010中构建它.但由于链接器提示错误-LINK:致命错误LNK1181:无法打开输入文件X.lib',因此构建失败.

I am a newbie in the Visual Studio 2010 environment. I got a source base which was developed using Visual Studio 2008. I am trying to build it in VS 2010; but the build fails as the Linker says the error - LINK : fatal error LNK1181: cannot open input file X.lib'.

此处X是从同一项目创建的lib文件的名称,X.dll是输出dll.实际上,项目中不存在X.lib.如果没有成功构建项目,Dll就无法成功构建.我该如何解决这种僵局"情况?

Here X is the name of the lib file created from the same project and X.dll is the output dll. In fact the X.lib is not present in the project. Without succesfully building the project, it won't come at all for the Dll to build succesfully. How can I resolve this "Deadlock" kind of situation?

预先感谢

Shiju

推荐答案

我也遇到了这个问题.将正常运行的VS2008项目转换为VS2010时,Link阶段在VS2010项目中中断,并出现相同的错误.它正在尝试链接应该建立该项目的.lib!

I had this problem also. When converting a working VS2008 project to VS2010, the Link phase breaks in the VS2010 project with the same error. It is trying to link the .lib that the project is supposed to be building!

我找到了问题的根源:该项目有一个自定义生成步骤,该步骤发生在生成结束时,即PostBuildEvent之前.这个自定义构建步骤将$ .Out,.lib和.pdb文件从$(OutDir)复制到外部位置.

I found the source of my problem: The project has a custom build step that occurs at the end of the build, before the PostBuildEvent. This custom build step copies the .dll, .lib and .pdb from $(OutDir) to an external location.

自定义构建步骤的输出列表设置为复制的.dll,.lib和.pdb的完整路径,例如:

The Outputs List for the custom build step is set to the full path to the copied .dll, .lib and .pdb, e.g.:

C:/a_new_location/myproject.dll;
C:/a_new_location/myproject.lib;
C:/a_new_location/myproject.pdb.

我发现,只要此输出列表包含.lib,该.lib就会添加到要在链接阶段链接的文件列表中.因此,使用上述输出列表,链接阶段将具有以下文件列表:

I found that whenever this Outputs List includes the .lib, that .lib gets added to list of files to link in the link phase. So with the above Outputs List, the link phase will have a file list of:

myprojectfile1.obj
myprojectfile2.obj
C:/a_new_location/myproject.lib

这会导致链接失败:

LINK : fatal error LNK1181: cannot open input file 'C:\a_new_location\G4SrcCfgLib.lib'

自定义构建步骤中的副本实际上是否复制文件都没有关系.重要的是输出列表包含.lib.因此,我通过从输出列表中删除.lib解决了该问题.不利的一面是,执行Clean build不会清理C:/a_new_location/lib.但是至少它可以构建.

It does not matter if the copy in the custom build step actually copies the file or not. All that matters is that the Outputs List includes the .lib. So, I resolved the problem by removing the .lib from the Outputs List, of course. The downside to this is that doing a Clean build will not clean C:/a_new_location/lib. But at least it builds.

这篇关于DLL项目无法建立,因为Linker无法找到相同的命名.lib文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆