Linking to a static library?

Started by
2 comments, last by CodeMunkie 12 years, 6 months ago
Hiya,

I have a weird problem with VS2010, I was hoping someone could help with.

I have a solution with two projects, a static library and a command-line application. I've added a 'reference' to the static-library, to say it should be linked with the application. Apparently this changed in VS2010 - I used to do it through the Project Dependencies, which no longer functions.

If I build the library by itself, everything is fine. I can see the library file is output successfully.

However for some strange reason, if I build the application it first deletes the library and then complains that it doesn't exist when it tries to link...

I'm not sure if the library is rebuilt first before it's deleted - the output suggests it is, but if so it is deleted again too quickly for me to see.

Does anyone have any idea what is going on?

Many thanks!
Advertisement
Here's the output, in case anyone can spot something..


------ Rebuild All started: Project: CryptoLib, Configuration: Debug Win32 ------
Build started 06/10/2011 19:13:06.
_PrepareForClean:
Deleting file "..\..\Obj\Debug\CryptoLib.lastbuildstate".
InitializeBuildStatus:
Creating "..\..\Obj\Debug\CryptoLib.unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
BigInteger.cpp
Lib:
CryptoLib.vcxproj -> C:\Users\Administrator\Desktop\T1\VS2010\CryptoLib\..\..\Bin\CryptoLib\Debug\CryptoLib_d.lib
FinalizeBuildStatus:
Deleting file "..\..\Obj\Debug\CryptoLib.unsuccessfulbuild".
Touching "..\..\Obj\Debug\CryptoLib.lastbuildstate".

Build succeeded.

Time Elapsed 00:00:00.81
------ Rebuild All started: Project: Gateway, Configuration: Debug Win32 ------
Build started 06/10/2011 19:13:07.
_PrepareForClean:
Deleting file "..\..\Obj\Debug\Gateway.lastbuildstate".
InitializeBuildStatus:
Touching "..\..\Obj\Debug\Gateway.unsuccessfulbuild".
ClCompile:
Main.cpp
GatewaySession.cpp
GatewayServer.cpp
Generating Code...
LINK : fatal error LNK1104: cannot open file 'C:\Users\Administrator\Desktop\T1\Bin\CryptoLib\Debug\CryptoLib_d.lib'

Build FAILED.

Time Elapsed 00:00:10.54
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========


In any case, the library is built but by the time it needs to be linked with, it's been deleted :/
I have totally had this issue before an it drove me nuts.

Try re-installing MSVS and recreating your projects/solutions.
If that doesn't work give up and become an escort. (or make another post)
Check out the possible causes here and see if any apply:
http://msdn.microsof...s(v=vs.71).aspx

If you can confirm that the file exists while you are building your project, then maybe it is a permissions thing. I find that things go smoother if I "Run as Administrator" when starting VS2010 (on Windows 7).
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.

This topic is closed to new replies.

Advertisement