虽然在zlib.lib中链接,但是未解析的外部 [英] Unresolved externals despite linking in zlib.lib

查看:1381
本文介绍了虽然在zlib.lib中链接,但是未解析的外部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试编译一个在VC ++ 2010中使用zlib压缩的应用程序。

I've been trying to compile an application which utilizes zlib compression in VC++ 2010.

我得到

error LNK2019: unresolved external symbol _inflateInit2_ referenced in function ...


$ b b

错误消息,这将不常见,如果我没有链接lib。我链接了静态发布的zlib库。

error message, which wouldn't be unusual if I didn't link the lib. I link the static release zlib library.

我已经设法获得完全相同的libs和标头配置在不同的解决方案中工作完美,因此这种行为是意想不到的。

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.

任何想法都会感激。

更新:Linker命令行

UPDATE: Linker command line

/ OUT:C:\Documents和Settings \Suthke\My Documents \Visual Studio 2010\Projects\SBRapGen2\Debug\SBRapGen2.exe/ INCREMENTAL / NOLOGOzlib.lib kernel32.libuser32.libgdi32.libwinspool.libcomdlg32.libadvapi32.libshell32.libole32.liboleaut32.libuuid.lib odbc32.libodbccp32.lib/ MANIFEST /ManifestFile:\"Debug\SBRapGen2.exe.intermediate.manifest/ ALLOWISOLATION / MANIFESTUAC:level ='asInvoker'uiAccess ='false'/ DEBUG / 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

UPDATE 2:详细的连结器输出:

UPDATE 2: 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_


推荐答案

如果您使用的VS2010解决方案贡献/意识到它的bug。 zlibstat项目定义了ZLIB_WINAPI,根据 zlib常见问题,它用于打开STDCALL约定。只需从项目设置中删除它并重新编译lib。

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.

这篇关于虽然在zlib.lib中链接,但是未解析的外部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆