Static linking question

Started by
2 comments, last by Uriel 18 years, 8 months ago
Hello! I have a following problem: I have created class using standard string. I tried to compile it to .lib, so it could be easly added to other projects. When i add that lib to any other project that also utilizes strings - im unable to link because string is already defined... i supposet there is some simple solution... any help on that one?
Advertisement
I'm not sure why you're getting that problem. Just because you're using strings in two separate classes you shouldn't get a redefinition error. As a quick workaround to your problem you can put all of your classes in the lib into their own namespace. This should clear up any redefinition problems.
Your lib and main program are probably linked to different versions of the standard libs. You can either force the linker to ignore symbols from the problem std lib or just rebuild them with the same lib. I tend to use 'multi-threaded dll' or 'multithreaded debug dll' for everything - seems to be the most forgiving.

If you're using msvc you can find the settings for this stuff in your project properties, under the 'c++/code generation' and 'linker/input' pages.
[size="1"]


*solved*

/NODEFAULTLIB:LIBCD helped after all. Thanks all for the help. I had a solution on screen all that time, heh.

[Edited by - Uriel on August 15, 2005 2:06:18 PM]

This topic is closed to new replies.

Advertisement