我一直在尝试编译一个在 VC++ 2010 中使用 zlib 压缩的应用程序。
我收到错误:
错误LNK2019:函数中引用了无法解析的外部符号inflateInit2...
如果我没有链接该库,这并不罕见。我链接了静态发布 zlib 库。
我已经设法使库和标头的完全相同的配置在不同的解决方案中完美工作,因此这种行为是非常出乎意料的。
任何想法将不胜感激。
链接器命令行:
/OUT:"C:\Documents and Settings\Suthke\My Documents\Visual Studio 2010\Projects\SBRapGen2\Debug\SBRapGen2.exe" /INCRMENTAL /NOLOGO "zlib.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” lib" /MANIFEST /ManifestFile:"Debug\SBRapGen2.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Documents and Settings\Suthke\我的文档\Visual Studio 2010\Projects\SBRapGen2\Debug\SBRapGen2.pdb" /SUBSYSTEM:CONSOLE /PGD:"C:\Documents and Settings\Suthke\My Documents\Visual Studio 2010\Projects\SBRapGen2\Debug\SBRapGen2.pgd “ /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE`
详细链接器输出:
1>------ 构建已开始:项目:SBRapGen2,配置:Release Win32 ------
1>
1>起始传球1
1>已处理 /DEFAULTLIB:uuid.lib
1>已处理 /DEFAULTLIB:msvcprt
1>已处理 /DEFAULTLIB:zlib.lib
1>已处理 /DEFAULTLIB:MSVCRT
1>已处理 /DEFAULTLIB:OLDNAMES
1>
1>搜索库
1>搜索 C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\zlib.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\advapi32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\shell32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\ole32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\oleaut32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\uuid.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\odbc32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\odbccp32.lib:
1>搜索 C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\msvcprt.lib:
1>搜索 C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\MSVCRT.lib:
1>找到@__security_check_cookie@4
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(secchk.obj)
1>找到 __imp__sprintf
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __imp__ceil
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>发现 __imp__free
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __imp__malloc
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __imp__printf
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __imp__fopen
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>发现 __imp__fread
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __imp__fwrite
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到__imp__ftell
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __imp__fseek
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __imp__fclose
1>在 SBRapGen2.obj 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到_mainCRTStartup
1>已加载 MSVCRT.lib(crtexe.obj)
1>发现___report_gsfailure
1>在MSVCRT.lib(secchk.obj)中引用
1>已加载 MSVCRT.lib(gs_report.obj)
1>找到 ___security_cookie
1>在MSVCRT.lib(secchk.obj)中引用
1>在MSVCRT.lib(gs_report.obj)中引用
1>已加载 MSVCRT.lib(gs_cookie.obj)
1>找到 __IMPORT_DESCRIPTOR_MSVCR100
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 ___CxxSetUnhandledExceptionFilter
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(unhandld.obj)
1>找到__amsg_exit
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __imp____getmainargs
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __dowildcard
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(通配符.obj)
1>找到__newmode
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(_newmode.obj)
1>发现_atexit
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(atonexit.obj)
1>找到__RTC_Terminate
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(initsect.obj)
1>找到 __imp___cexit
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>发现 __imp___exit
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __XcptFilter
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>发现__imp__exit
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __imp____initenv
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __IsNonwritableInCurrentImage
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(pesect.obj)
1>找到__initterm
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到___xc_a
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(cinitexe.obj)
1>已处理 /DEFAULTLIB:kernel32.lib
1>已处理 /DISALLOWLIB:libcmt.lib
1>已处理 /DISALLOWLIB:libcmtd.lib
1>已处理 /DISALLOWLIB:msvcrtd.lib
1>找到__initterm_e
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到___native_startup_state
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(natstart.obj)
1>找到__SEH_epilog4
1>在MSVCRT.lib(crtexe.obj)中引用
1>在 MSVCRT.lib(atonexit.obj) 中引用
1>已加载 MSVCRT.lib(sehprolg4.obj)
1>找到 __except_handler4
1>在MSVCRT.lib(crtexe.obj)中引用
1>在 MSVCRT.lib(atonexit.obj) 中引用
1>在MSVCRT.lib(pesect.obj)中引用
1>在MSVCRT.lib(sehprolg4.obj)中引用
1>已加载 MSVCRT.lib(chandler4gs.obj)
1>找到 __imp___configthreadlocale
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到___globallocalestus
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(xthdloc.obj)
1>找到 __setdefault precision
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(fp8.obj)
1>找到 __imp____setusermatherr
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到__matherr
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(merr.obj)
1>找到__setargv
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(dllargv.obj)
1>找到__commode
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(xncommod.obj)
1>找到 __imp___commode
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __imp___fmode
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __fmode
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(xtxtmode.obj)
1>找到 __imp____set_app_type
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 ___security_init_cookie
1>在MSVCRT.lib(crtexe.obj)中引用
1>已加载 MSVCRT.lib(gs_support.obj)
1>找到__crt_debugger_hook
1>在MSVCRT.lib(gs_report.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __NULL_IMPORT_DESCRIPTOR
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 MSVCR100_NULL_THUNK_DATA
1>在MSVCRT.lib(MSVCR100.dll)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到“void __cdecl终止(void)”(?terminate@@YAXXZ)
1>在MSVCRT.lib(unhandld.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>发现__unlock
1>在 MSVCRT.lib(atonexit.obj) 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>发现___dllonexit
1>在 MSVCRT.lib(atonexit.obj) 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>发现__lock
1>在 MSVCRT.lib(atonexit.obj) 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __imp___onexit
1>在 MSVCRT.lib(atonexit.obj) 中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到__ except_handler4_common
1>在MSVCRT.lib(chandler4gs.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __invoke_watson
1>在MSVCRT.lib(fp8.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>找到 __controlfp_s
1>在MSVCRT.lib(fp8.obj)中引用
1>已加载 MSVCRT.lib(MSVCR100.dll)
1>搜索 C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:
1>搜索 C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\zlib.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1>找到 __imp__InterlockedExchange@8
1>在MSVCRT.lib(crtexe.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__Sleep@4
1>在MSVCRT.lib(crtexe.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__InterlockedCompareExchange@12
1>在MSVCRT.lib(crtexe.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__HeapSetInformation@16
1>在MSVCRT.lib(crtexe.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__EncodePointer@4
1>在MSVCRT.lib(crtexe.obj)中引用
1>在 MSVCRT.lib(atonexit.obj) 中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__TerminateProcess@8
1>在MSVCRT.lib(gs_report.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__GetCurrentProcess@0
1>在MSVCRT.lib(gs_report.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__UnhandledExceptionFilter@4
1>在MSVCRT.lib(gs_report.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__SetUnhandledExceptionFilter@4
1>在MSVCRT.lib(gs_report.obj)中引用
1>在MSVCRT.lib(unhandld.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__IsDebuggerPresent@0
1>在MSVCRT.lib(gs_report.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__DecodePointer@4
1>在 MSVCRT.lib(atonexit.obj) 中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__QueryPerformanceCounter@4
1>在MSVCRT.lib(gs_support.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__GetTickCount@0
1>在MSVCRT.lib(gs_support.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__GetCurrentThreadId@0
1>在MSVCRT.lib(gs_support.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__GetCurrentProcessId@0
1>在MSVCRT.lib(gs_support.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __imp__GetSystemTimeAsFileTime@4
1>在MSVCRT.lib(gs_support.obj)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 __IMPORT_DESCRIPTOR_KERNEL32
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1> kernel32.lib(KERNEL32.dll)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>找到 KERNEL32_NULL_THUNK_DATA
1> kernel32.lib(KERNEL32.dll)中引用
1>加载kernel32.lib(KERNEL32.dll)
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\advapi32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\shell32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\ole32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\oleaut32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\uuid.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\odbc32.lib:
1>搜索 C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\odbccp32.lib:
1>搜索 C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\msvcprt.lib:
1>搜索 C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\MSVCRT.lib:
1>搜索 C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:
1>搜索 C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\zlib.lib:
1>
1>完成库搜索
1>
1>完成第1关
1>
1>SBRapGen2.obj:错误LNK2001:无法解析的外部符号_deflateEnd
1>SBRapGen2.obj:错误LNK2001:无法解析的外部符号inflateInit2
1>SBRapGen2.obj:错误LNK2001:无法解析的外部符号_inflate
1>SBRapGen2.obj:错误LNK2001:无法解析的外部符号_inflateEnd
1>SBRapGen2.obj:错误LNK2001:无法解析的外部符号_deflate
1>SBRapGen2.obj:错误LNK2001:无法解析的外部符号deflateInit2
I've been trying to compile an application which utilizes zlib compression in VC++ 2010.
I get the error:
error LNK2019: unresolved external symbol inflateInit2 referenced in function ...
Which wouldn't be unusual if I didn't link the lib. I link the static release zlib library.
I've managed to get this exact same configuration of libs and headers working perfectly in different solutions and hence this behavior is greatly unexpected.
Any ideas will be appreciated.
Linker command line:
/OUT:"C:\Documents and Settings\Suthke\My Documents\Visual Studio 2010\Projects\SBRapGen2\Debug\SBRapGen2.exe" /INCREMENTAL /NOLOGO "zlib.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" /MANIFEST /ManifestFile:"Debug\SBRapGen2.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Documents and Settings\Suthke\My Documents\Visual Studio 2010\Projects\SBRapGen2\Debug\SBRapGen2.pdb" /SUBSYSTEM:CONSOLE /PGD:"C:\Documents and Settings\Suthke\My Documents\Visual Studio 2010\Projects\SBRapGen2\Debug\SBRapGen2.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE`
Verbose linker output:
1>------ Build started: Project: SBRapGen2, Configuration: Release Win32 ------
1>
1> Starting pass 1
1> Processed /DEFAULTLIB:uuid.lib
1> Processed /DEFAULTLIB:msvcprt
1> Processed /DEFAULTLIB:zlib.lib
1> Processed /DEFAULTLIB:MSVCRT
1> Processed /DEFAULTLIB:OLDNAMES
1>
1> Searching libraries
1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\zlib.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\user32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\shell32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\ole32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\uuid.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\odbc32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\odbccp32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\msvcprt.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\MSVCRT.lib:
1> Found @__security_check_cookie@4
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(secchk.obj)
1> Found __imp__sprintf
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp__ceil
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp__free
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp__malloc
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp__printf
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp__fopen
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp__fread
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp__fwrite
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp__ftell
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp__fseek
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp__fclose
1> Referenced in SBRapGen2.obj
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found _mainCRTStartup
1> Loaded MSVCRT.lib(crtexe.obj)
1> Found ___report_gsfailure
1> Referenced in MSVCRT.lib(secchk.obj)
1> Loaded MSVCRT.lib(gs_report.obj)
1> Found ___security_cookie
1> Referenced in MSVCRT.lib(secchk.obj)
1> Referenced in MSVCRT.lib(gs_report.obj)
1> Loaded MSVCRT.lib(gs_cookie.obj)
1> Found __IMPORT_DESCRIPTOR_MSVCR100
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found ___CxxSetUnhandledExceptionFilter
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(unhandld.obj)
1> Found __amsg_exit
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp____getmainargs
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __dowildcard
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(wildcard.obj)
1> Found __newmode
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(_newmode.obj)
1> Found _atexit
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(atonexit.obj)
1> Found __RTC_Terminate
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(initsect.obj)
1> Found __imp___cexit
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp___exit
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __XcptFilter
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp__exit
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp____initenv
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __IsNonwritableInCurrentImage
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(pesect.obj)
1> Found __initterm
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found ___xc_a
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(cinitexe.obj)
1> Processed /DEFAULTLIB:kernel32.lib
1> Processed /DISALLOWLIB:libcmt.lib
1> Processed /DISALLOWLIB:libcmtd.lib
1> Processed /DISALLOWLIB:msvcrtd.lib
1> Found __initterm_e
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found ___native_startup_state
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(natstart.obj)
1> Found __SEH_epilog4
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Referenced in MSVCRT.lib(atonexit.obj)
1> Loaded MSVCRT.lib(sehprolg4.obj)
1> Found __except_handler4
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Referenced in MSVCRT.lib(atonexit.obj)
1> Referenced in MSVCRT.lib(pesect.obj)
1> Referenced in MSVCRT.lib(sehprolg4.obj)
1> Loaded MSVCRT.lib(chandler4gs.obj)
1> Found __imp___configthreadlocale
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found ___globallocalestatus
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(xthdloc.obj)
1> Found __setdefaultprecision
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(fp8.obj)
1> Found __imp____setusermatherr
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __matherr
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(merr.obj)
1> Found __setargv
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(dllargv.obj)
1> Found __commode
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(xncommod.obj)
1> Found __imp___commode
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp___fmode
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __fmode
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(xtxtmode.obj)
1> Found __imp____set_app_type
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found ___security_init_cookie
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded MSVCRT.lib(gs_support.obj)
1> Found __crt_debugger_hook
1> Referenced in MSVCRT.lib(gs_report.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __NULL_IMPORT_DESCRIPTOR
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found MSVCR100_NULL_THUNK_DATA
1> Referenced in MSVCRT.lib(MSVCR100.dll)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found "void __cdecl terminate(void)" (?terminate@@YAXXZ)
1> Referenced in MSVCRT.lib(unhandld.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __unlock
1> Referenced in MSVCRT.lib(atonexit.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found ___dllonexit
1> Referenced in MSVCRT.lib(atonexit.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __lock
1> Referenced in MSVCRT.lib(atonexit.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __imp___onexit
1> Referenced in MSVCRT.lib(atonexit.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __except_handler4_common
1> Referenced in MSVCRT.lib(chandler4gs.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __invoke_watson
1> Referenced in MSVCRT.lib(fp8.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Found __controlfp_s
1> Referenced in MSVCRT.lib(fp8.obj)
1> Loaded MSVCRT.lib(MSVCR100.dll)
1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\zlib.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\kernel32.lib:
1> Found __imp__InterlockedExchange@8
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__Sleep@4
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__InterlockedCompareExchange@12
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__HeapSetInformation@16
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__EncodePointer@4
1> Referenced in MSVCRT.lib(crtexe.obj)
1> Referenced in MSVCRT.lib(atonexit.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__TerminateProcess@8
1> Referenced in MSVCRT.lib(gs_report.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetCurrentProcess@0
1> Referenced in MSVCRT.lib(gs_report.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__UnhandledExceptionFilter@4
1> Referenced in MSVCRT.lib(gs_report.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__SetUnhandledExceptionFilter@4
1> Referenced in MSVCRT.lib(gs_report.obj)
1> Referenced in MSVCRT.lib(unhandld.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__IsDebuggerPresent@0
1> Referenced in MSVCRT.lib(gs_report.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__DecodePointer@4
1> Referenced in MSVCRT.lib(atonexit.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__QueryPerformanceCounter@4
1> Referenced in MSVCRT.lib(gs_support.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetTickCount@0
1> Referenced in MSVCRT.lib(gs_support.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetCurrentThreadId@0
1> Referenced in MSVCRT.lib(gs_support.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetCurrentProcessId@0
1> Referenced in MSVCRT.lib(gs_support.obj)
1> Loaded kernel32.lib(KERNEL32.dll)
1> Found __imp__GetSystemTimeAsFileTime@4
1> Referenced in MSVCRT.lib(gs_support.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> 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 SDKs\Windows\v7.0A\lib\user32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\gdi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\winspool.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\comdlg32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\advapi32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\shell32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\ole32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\oleaut32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\uuid.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\odbc32.lib:
1> Searching C:\Program Files\Microsoft SDKs\Windows\v7.0A\lib\odbccp32.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\msvcprt.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\MSVCRT.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\zlib.lib:
1>
1> Finished searching libraries
1>
1> Finished pass 1
1>
1>SBRapGen2.obj : error LNK2001: unresolved external symbol _deflateEnd
1>SBRapGen2.obj : error LNK2001: unresolved external symbol inflateInit2
1>SBRapGen2.obj : error LNK2001: unresolved external symbol _inflate
1>SBRapGen2.obj : error LNK2001: unresolved external symbol _inflateEnd
1>SBRapGen2.obj : error LNK2001: unresolved external symbol _deflate
1>SBRapGen2.obj : error LNK2001: unresolved external symbol deflateInit2
发布评论
评论(8)
如果您使用 contrib/ 中提供的 VS2010 解决方案,请注意它有错误。 zlibstat 项目定义了 ZLIB_WINAPI,根据 zlib FAQ,它用于打开 STDCALL 约定。只需将其从项目设置中删除并重新编译库即可。
If you are using the VS2010 solution provided in contrib/ be aware that it's bugged. The zlibstat project defines ZLIB_WINAPI which according to zlib FAQ is used to switch on the STDCALL convention. Just remove it from the project settings and recompile the lib.
就我而言,我修改了
读取 ucrt.lib;vcruntime.lib;msvcrt.lib;kernel32.lib
这使得 libz 能够在 Windows 10 下使用 VS2015 进行构建
确保构建类型为 /MD
这也是如果构建 libpng(需要 zlib),则相同的修改可以使用旧的默认“项目”文件成功构建。
In my case I amended
to read
ucrt.lib;vcruntime.lib;msvcrt.lib;kernel32.lib
This enabled libz to build under Windows 10 with VS2015
Ensuring the build type was /MD
This was also the case if building for libpng (that requires zlib), the same modifications enable successful building with the old included default 'projects' files.
就我而言,使用 zlib-vc140-static-64 (v1.2.11) 或
zlib_native
(v1.2.11)。 microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio" rel="nofollow noreferrer">NuGet 在 vs2017 中。in my case, install
zlib-vc140-static-64
(v1.2.11) orzlib_native
(v1.2.11) using NuGet within vs2017.一些大胆的建议:
尝试运行 dumpbin /symbols zlib.lib 来查看该库中的符号是否符合您的预期(即,是 inflateInit2 ) > 在那里?)。
如果构建当前依赖 lib 路径搜索来定位
zlib.lib
,请尝试指定库的完整绝对路径,以排除链接器在系统其他位置找到某些过时的 zlib 库的情况。另外,发布用于链接器的命令行(来自构建日志文件)。
更新:
如果您不小心混合了 32 位和 64 位组件(即
zlib.lib
文件是为 x86 构建的,而应用程序是为 x64 构建的),您可能会看到类似的行为)。链接器不会抱怨找不到 lib 文件,也不会抱怨 lib 文件中的对象适用于不同的平台。鉴于您的错误消息提到了一个没有任何修饰的符号,我敢打赌链接器正在构建一个 x64 应用程序,但 zlib.lib 可能有 x86 对象(因此有一个名为_inflateInit2
的符号在那里,用下划线或其他东西装饰)。(顺便说一句 - 我想知道是否可以在同一个 lib 文件中混合 x86 和 x64 对象,只要它们具有不同的名称。并不是说我想真正这样做)。
A few shot-in-the-dark suggestions:
Try running
dumpbin /symbols zlib.lib
to see if the symbols in that lib are as you expect (ie., isinflateInit2
in there?).If the build is currently relying on a lib path search to locate
zlib.lib
, try specifying the full absolute path to the library to rule out the linker finding some stale zlib library somewhere else on your system.Also, post the command line used for the linker (from the build log file).
Update:
You can see behavior like this if you're accidentally mixing 32-bit and 64-bit components (ie., the
zlib.lib
file is built for x86 and the application is being built for x64). The linker doesn't complain about not finding the lib file, nor does it complain that the objects in the lib file are for a different platform. Given that your error message mentions a symbol without any decoration, I'd bet that the linker is building an x64 application, but maybe the zlib.lib has x86 objects (and therefore there's a symbol named_inflateInit2
in there, decorated with an underscore or maybe something else).(as an aside - I wonder if it's possible to mix x86 and x64 objects in the same lib file as long as the have different names. Not that I want to actually do this).
您是否验证了您的 zlib 函数原型位于
extern "C"
块中?如果不是,则链接器将查找具有 C++ 损坏名称的函数,而 zlib.lib 将包含未损坏的 C 名称。Did you verify that your zlib function prototypes are in an
extern "C"
block? If not, then the linker will be looking for functions with C++-mangled names, while zlib.lib will contain the unmangled C names.我自己使用 Visual Studio 2017 遇到了同样的问题。我收到了如下错误消息:
我按照 Michael Burr 的提示,检查我的 zlib 文件是否包含这些方法:
输出显示方法在那里,但 Visual Studio 仍然抱怨。最终,我从他们的 github 存储库下载了 zlib 的最新稳定版本,然后对其进行编译(使用 Visual Studio 开发人员控制台)。尽管最终我找到了他们的 MS Makefile,其中包含我需要运行的命令,但他们的说明并没有直接帮助。
查看他们的 win32/Makefile.msc 文件以获取有关构建过程的更多信息。
构建过程生成了两个 .lib 文件。我的项目中真正需要的是“zdll.lib”。 (有关信息,请参阅他们的文档文件 DLL_FAQ.txt)。回到 Visual Studio 中,我必须手动将文件添加到我的项目中(不使用
链接器 --> 常规 --> 其他库目录< /code> 方法,因为这引发了其他问题。)您可以通过右键单击解决方案对象来添加它们(不是列表中最上面的项目,而是第二个项目。在下图中,我的项目称为 Lasso,因此您需要单击项目中的等效项。)
转到:添加 --> Existing Item...
然后选择生成的zdll.lib文件。
明确添加到 Visual Studio 项目的 Lib 文件
I ran into the same problem myself using Visual Studio 2017. I got error messages like:
I followed the tip from Michael Burr, checking if the zlib file I had contained these methods:
The output showed the methods were there, yet Visual Studio still complained. Ultimately I downloaded the latest stable release of zlib from their github repository, and then compiled it (using a Visual Studio Developer Console). Their instructions were not directly helpful though eventually I found their MS Makefile which contained the command I needed to run.
Have a look inside their win32/Makefile.msc file for more information on the building process.
The build process generated two .lib files. What I really needed in my project was the one called 'zdll.lib'. (See their documentation file DLL_FAQ.txt for info on it). Back inside Visual Studio, I had to manually add the file to my project (NOT using the
Linker --> General --> Additional Library Directories
method, since this triggered the other problems.) You can add them by Right-Clicking on the Solution Object (Not the topmost item in the list, but the second item. In the picture below, my project is called Lasso, so you would want to click on the equivalent in your project.)Go to: Add --> Existing Item...
Then select the generated zdll.lib file.
Lib files explicitly added to Visual Studio project
您使用 VC++ 2010 以外的其他工具编译了 zlib 静态库吗?
这是 VS2008/05 的最新升级吗?
您是否尝试过使用 2010 工具集重新编译静态库?
You compiled the zlib static library using something other than VC++ 2010?
Is this a recent upgrade from VS2008/05?
Have you tried recompiling the static library using the 2010 toolset?
请注意,库的顺序很重要。假设您想要链接 A.OBJ、B.LIB 和 C.LIB,并按此顺序指定输入文件。如果 C.LIB 调用 B.LIB 中的函数,则不会找到该函数(除非已经从 A.OBJ 偶然调用了该函数)。
这可能是您问题的根源吗?
Be aware that the order of the libraries matters. Suppose you want to link A.OBJ, B.LIB, and C.LIB, with the input files specified in this order. If C.LIB calls a function in B.LIB, it won't be found (unless it was already fortuitously called from A.OBJ).
Could this be the source of your problem?