using _variant_t rather than _bstr_t causing linker error LNK2005 
Author Message
 using _variant_t rather than _bstr_t causing linker error LNK2005

Hi All,
I have a Win32 Dll (not using MFC).  Within it, I have a class that has the following member variable:

#include <comdef.h>
#include <map>
...
std::map<_bstr_t, std::map<_bstr_t, _bstr_t> > m_mapMVSCollection;

This compiles and links just fine.  When I change the above line to:

std::map<_bstr_t, std::map<_bstr_t, _variant_t> > m_mapMVSCollection;

I get the following linker errors and warnings.

Linking...
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __malloc_dbg already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: __free_dbg already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(dbgheap.obj) : warning LNK4006: __malloc_dbg already defined in msvcrtd.lib(MSVCRTD.dll); second definition ignored
LIBCMTD.lib(dbgheap.obj) : warning LNK4006: __free_dbg already defined in msvcrtd.lib(MSVCRTD.dll); second definition ignored
LIBCMTD.lib(crt0init.obj) : warning LNK4006: ___xc_z already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
LIBCMTD.lib(crt0init.obj) : warning LNK4006: ___xc_a already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
LIBCMTD.lib(crt0init.obj) : warning LNK4006: ___xi_z already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
LIBCMTD.lib(crt0init.obj) : warning LNK4006: ___xi_a already defined in msvcrtd.lib(cinitexe.obj); second definition ignored
   Creating library Debug/MyDll.lib and object Debug/MyDll.exp
LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
LIBCMTD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/MyDll.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Any advice would be greatly appreciated.

Thanks,
Tony



Wed, 24 Dec 2003 05:17:44 GMT  
 using _variant_t rather than _bstr_t causing linker error LNK2005
Hi,

Please try the following steps:
1. It seems that you've included msvcrtd.lib and libcmtd.lib, both of which
are C run-time libraries. Check your link line and make sure you haven't
specified one of them there. If you haven't, then a library that you are
linking is pulling one of them in or you've compiled files with different
options for CRT.

2. Remove _ATL_MIN_CRT from preprocessor definition in C/C++ tab of Project
Settings dialog box.

If the errors still exist, please ZIP the project and send it to

Regards,
HuangTM



Fri, 26 Dec 2003 20:02:40 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Link Errors using COM support classes _variant_t and _bstr_t

2. VC 7.0 Linker Error LNK2005, LNK4006, LNK1169 _DllMain@12 already defined in MyDll.obj

3. Linker Error LNK2005

4. LNK2005 linker error

5. New COM interface causing LNK2005 error

6. help...Linker error: LNK2005

7. vector<string> causes LNK2005/4006 errors

8. Linker Tools Error LNK2005

9. linker error LNK2005

10. Linker error LNK2005 ????

11. What is causing "error LNK2005:..."?

12. HUGE causes linker error

 

 
Powered by phpBB® Forum Software