Static Library Question

T

tsract

Is there a way to link a static lib I built using Visual Studio 2008 into a
Visual Studio 2005 project.

Recompiling the Visual Studio 2008 code is something we're trying to avoid.
 
C

Carl Daniel [VC++ MVP]

tsract said:
Is there a way to link a static lib I built using Visual Studio 2008
into a Visual Studio 2005 project.

Recompiling the Visual Studio 2008 code is something we're trying to
avoid.

Sure. Just include it in the link. Of course, successful linking is only
part of the problem - you'd probably like the code to work, too!

Whether you can successfully take a 2008 .lib and link it with other code
from 2005 will depend on what's in the library. Specifically, if it makes
any use at all of the C++ standard library, MFC or ATL, there's a chance -
maybe a good chance - that it won't work. On the other hand, if it's 100%
pure C++ or C code that doesn't depend on any VC++ libraries, there's a
pretty good chance that it will "just work".

Bottom line: there are no guarantees, but it might work.

-cd
 
T

tsract

Thanks for the answer.

I have two questions about compiler settings in 2008 regarding building the
lib.

1) Are there any "DEFINITELY DO THIS" compiler setttings I should use in the
VS2008 project?

2) Are there any compiler settings I should "DEFINITELY NOT USE"?
 
B

Bo Persson

tsract said:
Thanks for the answer.

I have two questions about compiler settings in 2008 regarding
building the lib.

1) Are there any "DEFINITELY DO THIS" compiler setttings I should
use in the VS2008 project?

2) Are there any compiler settings I should "DEFINITELY NOT USE"?

Not really.

If at all possible, compile all the code with the same compiler, using
the same settings.

If that is not possible (and just not a tad inconvenient), just try it
and see what the linker says. Like Carls writes, the odds are high
that there will be complaints. But if not, it just might work - by
luck.


Bo Persson
 
C

Carl Daniel [VC++ MVP]

tsract said:
Thanks for the answer.

I have two questions about compiler settings in 2008 regarding
building the lib.

1) Are there any "DEFINITELY DO THIS" compiler setttings I should use
in the VS2008 project?

2) Are there any compiler settings I should "DEFINITELY NOT USE"?

VC2005 and VC2008 are very similar at the compiler/linker level. Generally,
if you use the same compiler settings for both, you've got very good odds
that the generated code is mixable. Again, if the code makes any use of the
C++ standard library, MFC or ATL, especially in the public interface of the
library, then all bets are off.

You might want to consult this list of breaking changes in VC2008 as well:
any use of the features covered here are likely to lead to an undesirable
result.

http://msdn.microsoft.com/en-us/library/bb531344.aspx

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top