0

I have a C++ static library that depends on standard library. It is build OK if I select to link standard library as DLL. However, if I link it as LIB, I have problem. My library refers to static standard library, and my EXE refers to standard library and MFC, and I receive error messages that "function XXX already defined" (here XXX means any standard library function, like operator new, free, malloc, etc). So, it looks like my static C++ library exports not only its own functions, but also standard library functions, and they are imported into C++ program 2 times. Is there any way to fix this issue and create static library that uses static standard library?

3
  • Please paste how you're declaring those functions. Jan 27, 2013 at 8:06
  • If you are about standard library functions, I use standard C/C++ include directive like #include <memory> or #include <cstdio>
    – Vitalii
    Jan 27, 2013 at 8:21
  • Can you be a little more specific on a few of the error messages (as in post them in your question (not here in a comment) please? Just 3-5 of them should be sufficient.
    – WhozCraig
    Jan 27, 2013 at 8:48

1 Answer 1

0

Your static library contains a whole copy of the standard lib, you statically linked the two together. Obviously, linking that library into your application causes duplicate symbols. Maybe linking the app statically, could fix that because the linker might discard these duplicate copies of the standard lib, but I don't think that works with MFC. Link your static lib agains the DLL standard lib, this might sound like a contradiction but isn't really.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.