A Dll project is not created because Linker cannot find the same .lib file.

I am new to Visual Studio 2010. I got a source database that was developed using Visual Studio 2008. I am trying to create it in VS 2010; but the assembly fails because Linker reports an error - LINK: fatal error LNK1181: cannot open the X.lib 'input file.

Here, X is the name of the lib file created from the same project, and X.dll is the output dll. In fact, X.lib is missing from the project. Without successful development of the project, it will not work for Dll to succeed. How can I solve this "dead end" situation?

Thanks in advance,

Shiju

+2
source share
1 answer

I also had this problem. When converting a working VS2008 project to VS2010, the communication phase is broken in the VS2010 project with the same error. He is trying to link .lib that the project should be built!

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

In the Outputs list for the custom build stage, the full path to the copied .dll, .lib and .pdb is set, for example:

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

I found that whenever this list of results includes .lib, this .lib is added to the list of files for the link in the link phase. Thus, with the above list of outputs, the communication phase will have a list of files:

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

And this 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 user build copies a copy of the file or not. All that matters is that there is a .lib in the list of results. So, I solved the problem, of course, removing .lib from the Outputs list. The disadvantage of this is that running the Clean assembly will not clear C: / a_new_location / lib. But at least he is building.

+1
source

All Articles