I'm new to Visual Studio and Windows as a development platform, and I'm having troubles linking a static library from one 'Project' into an executable in another. The library builds without error, but linking bails after finding several STL template instantiations defined in the library.
For the purpose of this question, Project A builds a static library, which I then attempt to link with in Project B.
I'm hoping someone can point out what I'm missing here.
The build command line for Project A:
/Od <includes> /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_WIN32_WINNT=0x0501" /D "DEBUG" /D "WS4_WIN32" /D "AF" /D "_VC80_UPGRADE=0x0710" /D "_MBCS" /Gm /EHsc /RTC1 /MTd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /Wp64 /ZI /TP /wd4290 /errorReport:prompt
The build and link command lines for Project B:
/Od <includes> /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /wd4290 /errorReport:prompt
/OUT:<exe name> /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"<exe name>.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:<pdb name> /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib <Project A Lib file>
When the linker runs, I get a ton of errors of the following form:
msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "<some STL template instantiation>" (<mangled name>) already defined in <Project A>.lib(<some Project A object>.obj)
I think this is telling me that an STL instantiation defined in an object of my library is also defined in msvcprtd.lib. What's not clear to me is if I'm not building my static library correctly, or if my linker settings are wrong. I would appreciate any guidance on this.