Sign in to follow this  

Linking to a static library?

Recommended Posts


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!

Share this post

Link to post
Share on other sites
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.
Deleting file "..\..\Obj\Debug\CryptoLib.lastbuildstate".
Creating "..\..\Obj\Debug\CryptoLib.unsuccessfulbuild" because "AlwaysCreate" was specified.
CryptoLib.vcxproj -> C:\Users\Administrator\Desktop\T1\VS2010\CryptoLib\..\..\Bin\CryptoLib\Debug\CryptoLib_d.lib
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.
Deleting file "..\..\Obj\Debug\Gateway.lastbuildstate".
Touching "..\..\Obj\Debug\Gateway.unsuccessfulbuild".
Generating Code...
LINK : fatal error LNK1104: cannot open file 'C:\Users\Administrator\Desktop\T1\Bin\CryptoLib\Debug\CryptoLib_d.lib'


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 :/

Share this post

Link to post
Share on other sites
Check out the possible causes here and see if any apply:

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).

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this