VS2005 C++ project: linkage errors under MultiThreaded-DLL runtime lib', but compiles fine under Multithreaded-DEBUG dll ?!?

Hi,

I am in the process of moving our development to VS2005 from VS2003.
One of our C++ projects now runs properly in debug mode, and in release mode when using the multithreaded-debug-dll runtime libs, but does is fails during linkage when in release more and using the multithreaded-(release)-dll [which it is supposed to].

- The project combines managed and unmanaged code.
- The error repeats itself both in the original managed C++ syntax, and now in the new C++/CLI syntax.
- Other C++ projects I have moved to VS2005 do not have this issue.

The linkage error is below in italic.

Any ideas ! Tongue Tied

Thanks,
5spot

MSVCMRT.lib(mstartup.obj) : error LNK2028: unresolved token (0A00008D) "extern "C" void __cdecl __security_init_cookie(void)" ( __security_init_cookie@@$$J0YAXXZ) referenced in function "private: void __thiscall <CrtImplementationDetails>::LanguageSupport::InitializeNative(void)" ( InitializeNative@LanguageSupport@<CrtImplementationDetails>@@$$FAAEXXZ)

MSVCMRT.lib(mstartup.obj) : error LNK2020: unresolved token (0A00008F) __native_vcclrit_reason

MSVCMRT.lib(mstartup.obj) : error LNK2020: unresolved token (0A000095) __native_startup_state

MSVCMRT.lib(mstartup.obj) : error LNK2020: unresolved token (0A0000E4) __native_startup_lock

MSVCMRT.lib(mstartup.obj) : error LNK2020: unresolved token (0A0000E5) __native_dllmain_reason

MSVCMRT.lib(managdeh.obj) : error LNK2028: unresolved token (0A000037) "extern "C" int __cdecl __FrameUnwindFilter(struct _EXCEPTION_POINTERS *)" ( __FrameUnwindFilter@@$$J0YAHPAU_EXCEPTION_POINTERS@@@Z) referenced in function "extern "C" void __clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)" ( ___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z)

Given.MIL.obj : error LNK2019: unresolved external symbol __vswprintf referenced in function "int __cdecl swprintf(wchar_t *,wchar_t const *,...)" ( swprintf@@YAHPA_WPB_WZZ)

MSVCMRT.lib(mstartup.obj) : error LNK2001: unresolved external symbol ___native_dllmain_reason

MSVCMRT.lib(mstartup.obj) : error LNK2001: unresolved external symbol ___native_vcclrit_reason

MSVCMRT.lib(mstartup.obj) : error LNK2001: unresolved external symbol ___native_startup_state

MSVCMRT.lib(mstartup.obj) : error LNK2019: unresolved external symbol "extern "C" void __cdecl __security_init_cookie(void)" ( __security_init_cookie@@$$J0YAXXZ) referenced in function "private: void __thiscall <CrtImplementationDetails>::LanguageSupport::InitializeNative(void)" ( InitializeNative@LanguageSupport@<CrtImplementationDetails>@@$$FAAEXXZ)

MSVCMRT.lib(mstartup.obj) : error LNK2001: unresolved external symbol ___native_startup_lock

MSVCMRT.lib(managdeh.obj) : error LNK2019: unresolved external symbol "extern "C" int __cdecl __FrameUnwindFilter(struct _EXCEPTION_POINTERS *)" ( __FrameUnwindFilter@@$$J0YAHPAU_EXCEPTION_POINTERS@@@Z) referenced in function "extern "C" void __clrcall ___CxxCallUnwindDtor(void (__clrcall*)(void *),void *)" ( ___CxxCallUnwindDtor@@$$J0YMXP6MXPAX@Z0@Z)



Answer this question

VS2005 C++ project: linkage errors under MultiThreaded-DLL runtime lib', but compiles fine under Multithreaded-DEBUG dll ?!?

  • TechCzech

    Everyone: you cannot mix and match versions of the lib created from different versions of the compiler.  Example: you cannot use a VC 2003, 2002, or 6.0 version of msvcrt.lib with VC 2005.    It simply will not work, don't waste your time trying.   This also means you cannot use a static library created with VC 2003, 2002, or 6.0 that has references to the runtime libraries. 

    If you want to use the runtime library in 2005, you must use the library files provided with Visual C++ 2005.  These libraries are in \Program Files\Microsoft Visual Studio 8\VC\Lib

    Once again, please do not try using the wrong versions of runtime import libraries or static libraries with Visual C++ 2005.


  • eduboys

    Nikola,

    Nope, neither of these are switched.

    Here are my C++ options: ('XXXXX' placed to hide all specific identification)

    /O2 /Ob1 /AI "..\XXXXX\bin\Release" /D "WIN32" /D "NDEBUG" /D "_VC80_UPGRADE=0x0710" /D "_WINDLL" /D "_MBCS" /FD /EHa /MD /Yu"stdafx.h" /Fp"Release\XXXXX.pch" /Fo"Release\\" /Fd"Release\vc80.pdb" /W3 /nologo /c /Zi /clr /TP /errorReport:prompt

    Here are my linker options:

    /OUT:"Release/XXXXX.dll" /INCREMENTAL:NO /NOLOGO /DLL /MANIFEST /MANIFESTFILE:"Release\XXXXX.dll.intermediate.manifest" /FIXED:No /KEYFILE:"XXXXX" /ERRORREPORT:PROMPT mil.lib milvga.lib milim.lib milblob.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

    The errors do not disappear if I specifically add the 'msvcrt.lib' either.
    And again, everything is find if I use the Debug-DLL runtime (! ! !)

    Any ideas

    Thanks!!
    5spot

  • Ratul Saikia

    All of these symbols are defined in msvcrt.lib. So either you have /nodefaultlib:msvcrt.lib on the linker command line or you use /noentry or both. Anyway you have to link with msvcrt.lib. Posting list of switches you pass to the linker may help to narrow down the problem.

    Nikola
    VC++



  • Ske25et

     5spot wrote:
    One of our C++ projects now runs properly in debug mode, and in release mode when using the multithreaded-debug-dll runtime libs, but does is fails during linkage when in release more and using the multithreaded-(release)-dll [which it is supposed to].


    I don't understand the second half of this sentence, but if your first half is correct in saying that you're trying to use the debug-flavored CRT DLL for a release build, you're using an unsupported combination.

    Brian

  • Kees van der Oord

    If my main application is C/C++, the runtime libraries (/MT,/MD,/ML and version) of the C/C++ DLL must match the one of the main application.

    If my main application is VB, I'm free to choose whatever runtime libraries (/MT,/MD,/ML) I like in the C/C++ DLL.

    Is this correct


  • _ _

    What are the correct runtime libraries if my main application is VB6

    And how can i figure out the correct runtime libraries, if i don't know the programming language of the main application


  • Beav1810

    Claude, since you are using VB6 as your main application, the correct runtime libraries are the ones that go along with what ever component you write that is called by your VB 6 app. e.g. you create a DLL in C++ in Visual C++ 2005 and call this DLL from your VB6 app, so you would be using the CRT from Visual C++ 2005.

    If your VB6 app does not call any of your own C++ components then the minimum files are in the operting system (msvcrt.dll) and VB6 redistribution packs, i.e.

    http://www.microsoft.com/downloads/details.aspx FamilyID=bf9a24f9-b5c5-48f4-8edd-cdf2d29a79d5&DisplayLang=en


  • nrb1955

    ------



  • KevinUT

    i encounter same program.
    i try to using
    "${Matrox imaging}\mil\library\winnt\msc\dll\msvcrt.lib",
    don't using default msvcrt.lib.

  • maxima

    Sorry, but that not a serious answer. The problem is real, and exists only in the "supported" combination of release and runtime release-dll.
    The only hint I have is that the debug DLL does work OK with the release build (perhaps unsupported, but at least it compiles and runs properly...). The runtime release DLL seems to be missing some symbols that are needed, and that exist in the debug DLL.

    Anyone know what is going on here
    Thanks,
    5 spot

  • VS2005 C++ project: linkage errors under MultiThreaded-DLL runtime lib', but compiles fine under Multithreaded-DEBUG dll ?!?