Visual Studio: LINK : fatal error LNK1181: cannot open input file

后端 未结 17 2802
盖世英雄少女心
盖世英雄少女心 2020-12-05 03:47

I\'ve been encountering a strange bug in Visual Studio 2010 for some time now.

I have a solution consisting of a project which compiles to a static library, and anot

17条回答
  •  一生所求
    2020-12-05 04:23

    I'm stumbling into the same issue. For me it seems to be caused by having 2 projects with the same name, one depending on the other.

    For example, I have one project named Foo which produces Foo.lib. I then have another project that's also named Foo which produces Foo.exe and links in Foo.lib.

    I watched the file activity w/ Process Monitor. What seems to be happening is Foo(lib) is built first--which is proper because Foo(exe) is marked as depending on Foo(lib). This is all fine and builds successfully, and is placed in the output directory--$(OutDir)$(TargetName)$(TargetExt). Then Foo(exe) is triggered to rebuild. Well, a rebuild is a clean followed by a build. It seems like the 'clean' stage of Foo.exe is deleting Foo.lib from the output directory. This also explains why a subsequent 'build' works--that doesn't delete output files.

    A bug in VS I guess.

    Unfortunately I don't have a solution to the problem as it involves Rebuild. A workaround is to manually issue Clean, and then Build.

提交回复
热议问题