This simple example won't link - unresolved external symbols for std::runtime_error (build log follows example).
Command line for build:
/Od /I "C:\Program Files\Microsoft Platform SDK\Include" /I "C:\Program Files\Microsoft Platform SDK\Include\atl" /I "C:\Program Files\Microsoft Platform SDK\Include\crt" /I "C:\Program Files\Microsoft Platform SDK\Include\gl" /I "C:\Program Files\Microsoft Platform SDK\Include\mfc" /D "_MBCS" /Gm /EHsc /RTC1 /MDd /GS- /arch:SSE2 /Fo"Debug\\" /Fd"Debug\vc80.pdb" /FR"Debug\\" /W3 /nologo /c /Wp64 /ZI /TP /errorReport:prompt
Source code:
#include <stdexcept>
#include
<windows.h>int
__stdcall WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){
std::runtime_error re(
"123"); return 0;}
Build log:
1>------ Build started: Project: Burekas, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>Linking...
1>main.obj : error LNK2019: unresolved external symbol __imp_ 1runtime_error@std@@UAE@XZ referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol __imp_ 0runtime_error@std@@QAE@ABV $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@1@@Z referenced in function _WinMain@16
1>Debug\Burekas.exe : fatal error LNK1120: 2 unresolved externals
1>Creating browse information file...
1>Microsoft Browse Information Maintenance Utility Version 8.00.50215
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Build log was saved at "file://c:\Documents and Settings\zigfried\My Documents\Visual Studio 2005\Projects\Burekas\Burekas\Debug\BuildLog.htm"
1>Burekas - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Anyone has an idea
std::exception works fine, other STL templates work fine as well.
Thanks,
Moshe

Visual C++ express beta 2: can't link std::runtime_error
Mohammad Al Husseiny
I would try such released bits of VC2005 with the sample at: http://msdn.microsoft.com/library/default.asp url=/library/en-us/vcstdlib/html/vclrf_stdexcept_Runtimeerror_class.asp. If that still doesn't work, please log a bug at http://lab.msdn.microsoft.com/productfeedback/default.aspx
Thanks,
Ayman Shoukry
VC++ Team
Tom Trenka
I found the problem
Simply place the Platform SDK C runtime include directory (in my computer - "C:\Program Files\Microsoft Platform SDK\Include\crt") before the VC install directory include path ($(VCInstallDir)include).
Make sure you rebuild everything, and the error is reproduced.
You may want to add this issue to a KB or maybe fix the problem somehow.
Thanks for your help,
Moshe Gottlieb
hberenson
I tried using the latest VC2005 bits. Could you try the released bits of VC2005
Also, what is the link command Could you try using the /verbose linker option which should show more details
Thanks,
Ayman Shoukry
VC++ Team
Jamil Afza
I'm using the latest vc express (beta 2), that's the newest released version, for all i can gather.
After adding /verbose to the linker, i'm getting this build log:
1>------ Build started: Project: Burekas, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>Linking...
1>Starting pass 1
1>Processed /DEFAULTLIB:msvcprtd
1>Processed /DEFAULTLIB:uuid.lib
1>Processed /DEFAULTLIB:MSVCRTD
1>Processed /DEFAULTLIB:OLDNAMES
1>Searching libraries
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\kernel32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\user32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\winspool.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\shell32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\ole32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\uuid.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcprtd.lib:
1> Found __imp_ 1 $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@QAE@XZ
1> Referenced in main.obj
1> Loaded msvcprtd.lib(MSVCP80D.dll)
1> Found __imp_ 0 $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@std@@QAE@PBDABV $allocator@D@1@@Z
1> Referenced in main.obj
1> Loaded msvcprtd.lib(MSVCP80D.dll)
1> Found __IMPORT_DESCRIPTOR_MSVCP80D
1> Referenced in msvcprtd.lib(MSVCP80D.dll)
1> Referenced in msvcprtd.lib(MSVCP80D.dll)
1> Loaded msvcprtd.lib(MSVCP80D.dll)
1> Found __NULL_IMPORT_DESCRIPTOR
1> Referenced in msvcprtd.lib(MSVCP80D.dll)
1> Loaded msvcprtd.lib(MSVCP80D.dll)
1> Found MSVCP80D_NULL_THUNK_DATA
1> Referenced in msvcprtd.lib(MSVCP80D.dll)
1> Loaded msvcprtd.lib(MSVCP80D.dll)
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\MSVCRTD.lib:
1> Found @_RTC_CheckStackVars@8
1> Referenced in main.obj
1> Loaded MSVCRTD.lib(stack.obj)
1> Found __RTC_Shutdown
1> Referenced in main.obj
1> Loaded MSVCRTD.lib(init.obj)
1> Found _WinMainCRTStartup
1> Loaded MSVCRTD.lib(crtexew.obj)
1> Found "void __cdecl _RTC_Failure(void *,int)" ( _RTC_Failure@@YAXPAXH@Z)
1> Referenced in MSVCRTD.lib(stack.obj)
1> Loaded MSVCRTD.lib(error.obj)
1> Found _memset
1> Referenced in MSVCRTD.lib(stack.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __RTC_SetErrorFuncW
1> Referenced in MSVCRTD.lib(init.obj)
1> Loaded MSVCRTD.lib(userapi.obj)
1> Found __CRT_RTC_INITW
1> Referenced in MSVCRTD.lib(init.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __imp___configthreadlocale
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found ___globallocalestatus
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(xthdloc.obj)
1> Found __setdefaultprecision
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(fp8.obj)
1> Found __imp____setusermatherr
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __matherr
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(merr.obj)
1> Found __setargv
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(dllargv.obj)
1> Found __RTC_Initialize
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(initsect.obj)
1> Found __adjust_fdiv
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(adjustfd.obj)
1> Found __imp___adjust_fdiv
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __commode
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(xncommod.obj)
1> Found __imp____p__commode
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __fmode
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(xtxtmode.obj)
1> Found __imp____p__fmode
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found ___onexitbegin
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(atonexit.obj)
1> Found __imp____set_app_type
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __amsg_exit
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __imp____getmainargs
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __dowildcard
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(wildcard.obj)
1> Found __newmode
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(_newmode.obj)
1> Found __imp___exit
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __XcptFilter
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __imp___cexit
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __imp__exit
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __imp___ismbblead
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __imp___acmdln
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __imp___CrtDbgReportW
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __initterm
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found ___xc_a
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(cinitexe.obj)
1>Processed /DEFAULTLIB:kernel32.lib
1> Processed /DISALLOWLIB:libc.lib
1> Processed /DISALLOWLIB:libcd.lib
1> Processed /DISALLOWLIB:libcmt.lib
1> Processed /DISALLOWLIB:libcmtd.lib
1> Processed /DISALLOWLIB:msvcrt.lib
1> Found __initterm_e
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found ___native_startup_state
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded MSVCRTD.lib(natstart.obj)
1> Found __except_list
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Referenced in MSVCRTD.lib(error.obj)
1> Loaded MSVCRTD.lib(dllsupp.obj)
1> Found __except_handler3
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Referenced in MSVCRTD.lib(error.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found "int __cdecl _RTC_GetSrcLine(unsigned char *,wchar_t *,unsigned long,int *,wchar_t *,unsigned long)" ( _RTC_GetSrcLine@@YAHPAEPA_WKPAH1K@Z)
1> Referenced in MSVCRTD.lib(error.obj)
1> Loaded MSVCRTD.lib(pdblkup.obj)
1> Found ___security_cookie
1> Referenced in MSVCRTD.lib(error.obj)
1> Referenced in MSVCRTD.lib(pdblkup.obj)
1> Loaded MSVCRTD.lib(seccook.obj)
1> Found @__security_check_cookie@4
1> Referenced in MSVCRTD.lib(error.obj)
1> Referenced in MSVCRTD.lib(pdblkup.obj)
1> Loaded MSVCRTD.lib(secchk.obj)
1> Found __IMPORT_DESCRIPTOR_MSVCR80D
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __controlfp_s
1> Referenced in MSVCRTD.lib(fp8.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __invoke_watson
1> Referenced in MSVCRTD.lib(fp8.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found ___dllonexit
1> Referenced in MSVCRTD.lib(atonexit.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found __imp___onexit
1> Referenced in MSVCRTD.lib(atonexit.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found ___security_init_cookie
1> Referenced in MSVCRTD.lib(secchk.obj)
1> Loaded MSVCRTD.lib(seccinit.obj)
1> Found ___report_gsfailure
1> Referenced in MSVCRTD.lib(secchk.obj)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Found MSVCR80D_NULL_THUNK_DATA
1> Referenced in MSVCRTD.lib(MSVCR80D.dll)
1> Loaded MSVCRTD.lib(MSVCR80D.dll)
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\kernel32.lib:
1> Found __imp__InterlockedExchange@8
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__Sleep@4
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__InterlockedCompareExchange@12
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetStartupInfoA@4
1> Referenced in MSVCRTD.lib(crtexew.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__RaiseException@16
1> Referenced in MSVCRTD.lib(error.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__DebugBreak@0
1> Referenced in MSVCRTD.lib(error.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__WideCharToMultiByte@32
1> Referenced in MSVCRTD.lib(error.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__MultiByteToWideChar@24
1> Referenced in MSVCRTD.lib(error.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__lstrlenA@4
1> Referenced in MSVCRTD.lib(error.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetProcAddress@8
1> Referenced in MSVCRTD.lib(error.obj)
1> Referenced in MSVCRTD.lib(pdblkup.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__LoadLibraryA@4
1> Referenced in MSVCRTD.lib(error.obj)
1> Referenced in MSVCRTD.lib(pdblkup.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetVersionExA@4
1> Referenced in MSVCRTD.lib(error.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__HeapFree@12
1> Referenced in MSVCRTD.lib(pdblkup.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__HeapAlloc@12
1> Referenced in MSVCRTD.lib(pdblkup.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetProcessHeap@0
1> Referenced in MSVCRTD.lib(pdblkup.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetModuleFileNameW@12
1> Referenced in MSVCRTD.lib(pdblkup.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__VirtualQuery@12
1> Referenced in MSVCRTD.lib(pdblkup.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__FreeLibrary@4
1> Referenced in MSVCRTD.lib(pdblkup.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__QueryPerformanceCounter@4
1> Referenced in MSVCRTD.lib(seccinit.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetTickCount@0
1> Referenced in MSVCRTD.lib(seccinit.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetCurrentThreadId@0
1> Referenced in MSVCRTD.lib(seccinit.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetCurrentProcessId@0
1> Referenced in MSVCRTD.lib(seccinit.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetSystemTimeAsFileTime@4
1> Referenced in MSVCRTD.lib(seccinit.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __IMPORT_DESCRIPTOR_KERNEL32
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found KERNEL32_NULL_THUNK_DATA
1> Referenced in kernel32.lib(KERNEL32.dll)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\user32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\winspool.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\shell32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\ole32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft Platform SDK\Lib\uuid.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\msvcprtd.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\MSVCRTD.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 8\VC\lib\OLDNAMES.lib:
1>Finished searching libraries
1>Finished pass 1
1>Generating non-SAFESEH image.
1>main.obj : error LNK2019: unresolved external symbol __imp_ 1runtime_error@std@@UAE@XZ referenced in function _WinMain@16
1>main.obj : error LNK2019: unresolved external symbol __imp_ 0runtime_error@std@@QAE@ABV $basic_string@DU $char_traits@D@std@@V $allocator@D@2@@1@@Z referenced in function _WinMain@16
1>Debug\Burekas.exe : fatal error LNK1120: 2 unresolved externals
1>Creating browse information file...
1>Microsoft Browse Information Maintenance Utility Version 8.00.50215
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Build log was saved at "file://c:\Documents and Settings\zigfried\My Documents\Visual Studio 2005\Projects\Burekas\Burekas\Debug\BuildLog.htm"
1>Burekas - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========