web-dev-qa-db-fra.com

Liens externes non résolus malgré la liaison dans zlib.lib

J'ai essayé de compiler une application qui utilise la compression zlib dans VC++ 2010. 

Je reçois le

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

message d'erreur, ce qui ne serait pas inhabituel si je ne liais pas la lib. Je lie la bibliothèque zlib de version statique. 

J'ai réussi à faire en sorte que la même configuration de libs et d'en-têtes fonctionne parfaitement dans différentes solutions, ce qui est tout à fait inattendu.

Toutes les idées sont les bienvenues.

UPDATE: ligne de commande de l'éditeur de liens 

/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

UPDATE 2: Sortie du lieur prolixe:

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_
28
RSuthke

Si vous utilisez la solution VS2010 fournie dans contrib /, sachez qu’elle a un bogue. Le projet zlibstat définit ZLIB_WINAPI qui, selon zlib FAQ est utilisé pour activer la convention STDCALL. Supprimez-le simplement des paramètres du projet et recompilez la bibliothèque.

75
Hook

J'ai trouvé ce lien utile pour moi. Travaillé comme un charme:

http://www.tannerhelland.com/5076/compile-zlib-winapi-wapi-stdcall/

4
Dula

Dans mon cas j'ai modifié

  • Config -> Linker -> Entrée -> Dépendances supplémentaires

lire ucrt.lib;vcruntime.lib;msvcrt.lib;kernel32.lib

Cela a permis à libz de construire sous Windows 10 avec VS2015

S'assurer que le type de construction était/MD

C'était également le cas si vous compiliez pour libpng (qui nécessite zlib), les mêmes modifications permettent de créer avec succès les anciens fichiers 'projets' par défaut. 

3
twobob

J'ai moi-même rencontré le même problème avec Visual Studio 2017. J'ai reçu des messages d'erreur tels que:

error LNK2019: unresolved external symbol __imp__deflate referenced in function 
error LNK2019: unresolved external symbol __imp__deflateEnd referenced in function 
error LNK2019: unresolved external symbol __imp__inflate referenced in function 
error LNK2019: unresolved external symbol __imp__inflateEnd referenced in function 
error LNK2019: unresolved external symbol __imp__deflateInit2_ referenced in function
error LNK2019: unresolved external symbol __imp__inflateInit2_ referenced in function

J'ai suivi le conseil de Michael Burr, vérifiant si le fichier zlib que j'avais contenait ces méthodes:

dumpbin /symbols zlib.lib

La sortie montrait que les méthodes existaient, mais Visual Studio s’est quand même plaint. En fin de compte, j'ai téléchargé la dernière version stable de zlib à partir de leur référentiel github, puis je l'ai compilé (à l'aide d'une console Visual Studio Developer). Leurs instructions n’ont pas été directement utiles, bien que j’ai trouvé leur fichier MS Makefile contenant la commande à exécuter.

nmake -f win32/Makefile.msc

Jetez un coup d'œil à l'intérieur de leur fichier win32/Makefile.msc pour plus d'informations sur le processus de construction.

Le processus de génération a généré deux fichiers .lib. Ce dont j'avais vraiment besoin dans mon projet était celui qui s'appelait 'zdll.lib'. (Voir leur fichier de documentation DLL_FAQ.txt pour plus d'informations). De retour dans Visual Studio, j'ai dû ajouter manuellement le fichier à mon projet (PAS à l'aide de la méthode Linker --> General --> Additional Library Directories, puisque cela a déclenché d'autres problèmes.) Vous pouvez les ajouter en cliquant à l'aide du bouton droit de la souris. sur l'objet Solution (ce n'est pas l'élément le plus haut de la liste, mais le deuxième. Dans l'image ci-dessous, mon projet s'appelle Lasso. Vous souhaitez donc cliquer sur l'équivalent dans votre projet.)

Aller à: Ajouter -> Article existant ...

Ensuite, sélectionnez le fichier zdll.lib généré.

Fichiers Lib explicitement ajoutés au projet Visual Studio

0
C.D.

Vous avez compilé la bibliothèque statique zlib en utilisant autre chose que VC++ 2010?

Est-ce une mise à jour récente de VS2008/05?

Avez-vous essayé de recompiler la bibliothèque statique à l'aide du jeu d'outils 2010?

0
J T

J'ai trouvé que cela liait OK dans Win32 mais pas x64.

0
Toby Sharp

Quelques suggestions inédites:

Essayez de lancer dumpbin /symbols zlib.lib pour voir si les symboles de cette bibliothèque sont comme vous le souhaitez (c'est-à-dire, est-ce que inflateInit2 est là?).

Si la construction s'appuie actuellement sur une recherche du chemin de la bibliothèque pour localiser zlib.lib, essayez de spécifier le chemin absolu complet de la bibliothèque pour exclure l'éditeur de liens de la recherche d'une bibliothèque zlib obsolète ailleurs sur votre système.

Affichez également la ligne de commande utilisée pour l'éditeur de liens (à partir du fichier journal de construction).

Mettre à jour:

Vous pouvez constater un tel comportement si vous mélangez par inadvertance des composants 32 bits et 64 bits (le fichier zlib.lib est créé pour x86 et l'application en cours de construction pour x64). L'éditeur de liens ne se plaint pas de ne pas avoir trouvé le fichier lib et ne se plaint pas non plus que les objets du fichier lib sont destinés à une plate-forme différente. Étant donné que votre message d'erreur mentionne un symbole sans décoration, je parierais que l'éditeur de liens est en train de créer une application x64, mais peut-être que le fichier zlib.lib contient des objets x86 (et qu'il y a donc un symbole nommé _inflateInit2 dans celui-ci, décoré avec un soulignement ou peut-être autre chose).

(en passant - je me demande s'il est possible de mélanger des objets x86 et x64 dans le même fichier lib tant qu'ils ont des noms différents. Ce n'est pas que je veuille réellement le faire).

0
Michael Burr

Sachez que l'ordre des bibliothèques est important. Supposons que vous souhaitiez lier A.OBJ, B.LIB et C.LIB aux fichiers d'entrée spécifiés dans cet ordre. Si C.LIB appelle une fonction dans B.LIB, elle ne sera pas trouvée (sauf si elle a déjà été appelée fortuitement depuis A.OBJ).
Cela pourrait-il être la source de votre problème?

0
TonyK

Avez-vous vérifié que vos prototypes de fonctions zlib sont dans un bloc extern "C"? Sinon, l'éditeur de liens recherchera des fonctions avec des noms mutilés en C++, tandis que zlib.lib contiendra les noms en C non démembrés.

0
Josh Kelley