Public Group

# Linking to a static library?

This topic is 2543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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. _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 :/

##### Share on other sites
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)

##### Share on other sites
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).

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
12
5. 5

• 14
• 9
• 22
• 9
• 31
• ### Forum Statistics

• Total Topics
632619
• Total Posts
3007491
• ### Who's Online (See full list)

There are no registered users currently online

×