Original Post
Alright, Im building a dll, in this dll I have one class (call it class A) that makes use of another class that is passed into it (class B). I have a static lib which class B is a part of. Now, the static lib builds fine and class B is used in the app (W32). Class B is initialized in the app, then passed into the class A (the dll class, which I get an instance of through GetProcAddress on a exported DLL function, that works). But, the only way I can get the DLL to build is if I have the classB.h/classB.cpp added to the DLL project. If I set the DLL project dependencies to use the static lib (where class B is) and just include the header for class B, I get the errors below. In short, put class B in static Lib, #include B in DLL project, get errors. Add classB.h/classB.cpp to DLL project, works. Ive been building the DLL by Adding the source file for B, Id like to use B through the static lib. Can anyone help me with this, or tell whats wrong and what to change, thanks. classA.cpp Linking... libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in classBstaticlib Lib.lib(classB.obj) libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in classBstaticlib Lib.lib(classB.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __cinit already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __exit already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___crtExitProcess already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __C_Termination_Done already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __exitflag already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __wpgmptr already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __pgmptr already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___winitenv already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __wenviron already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___initenv already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __environ already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___wargv already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___argv already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: ___argc already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __winminor already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __winmajor already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __winver already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __osver already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __osplatform already defined in LIBCMTD.lib(crt0dat.obj) LIBCD.lib(crt0dat.obj) : error LNK2005: __umaskval already defined in LIBCMTD.lib(crt0dat.obj) libcpmtd.lib(xlock.obj) : warning LNK4006: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in classBstaticlib Lib.lib(classB.obj); second definition ignored libcpmtd.lib(xlock.obj) : warning LNK4006: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in classBstaticlib Lib.lib(classB.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __cinit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: _exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __cexit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __c_exit already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___crtExitProcess already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __C_Exit_Done already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __C_Termination_Done already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __exitflag already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __wpgmptr already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __pgmptr already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___winitenv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __wenviron already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___initenv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __environ already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___wargv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___argv already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: ___argc already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __winminor already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __winmajor already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __winver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __osver already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __osplatform already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored LIBCD.lib(crt0dat.obj) : warning LNK4006: __umaskval already defined in LIBCMTD.lib(crt0dat.obj); second definition ignored Edit: Ive read/heard something about multi-threading having to do with this, but Im not using multiple threads and as far as I know, none of the libs for it either.