Sign in to follow this  
beebs1

Linking to a static library?

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Here's the output, in case anyone can spot something..

[code]
------ 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 ==========
[/code]

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:
[url="http://msdn.microsoft.com/en-us/library/ts7eyw4s(v=vs.71).aspx"]http://msdn.microsof...s(v=vs.71).aspx[/url]

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