Dll project doesn't build as Linker not able to find the same named .lib file
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'.
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?
Thanks in advance,
Shiju
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!
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.
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.
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
And that causes the link to fail:
LINK : fatal error LNK1181: cannot open input file 'C:\a_new_location\G4SrcCfgLib.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.
精彩评论