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
For me the problem was a wrong include
directory. I have no idea why this caused the error with the seemingly missing lib as the include directory only contains the header files. And the library directory had the correct path set.
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.
I created a bin
directory at the project_dir level, then created a release/debug
directory inside the bin
folder, which solved the problem for me.
I had the same problem. Solved it by defining a macro OBJECTS
that contains all the linker objects e.g.:
OBJECTS = target.exe kernel32.lib mylib.lib (etc)
And then specifying $(OBJECTS)
on the linker's command line.
I don't use Visual Studio though, just nmake and a .MAK file
Go to:
Project properties -> Linker -> General -> Link Library Dependencies set No.
I can see only 1 things happening here: You did't set properly dependences to thelibrary.lib in your project meaning that thelibrary.lib is built in the wrong order (Or in the same time if you have more then 1 CPU build configuration, which can also explain randomness of the error). ( You can change the project dependences in: Menu->Project->Project Dependencies )