title: Why cannot symbol be exported from static library?
body: <p>I'm building OpenCV using Visual Studio 2010. I'm using static CRT linkage (/MTd) and then link opencv.lib to my project. But there is a problem in my project with linking zlib, which is required by OpenCV:</p>
  
  <pre><code>Error   1   error LNK2019: unresolved external symbol _gzputs referenced in function "void __cdecl icvPuts(struct CvFileStorage *,char const *)" (?icvPuts@@YAXPAUCvFileStorage@@PBD@Z) o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj)   MyProject
  Error   2   error LNK2019: unresolved external symbol _gzclose referenced in function "void __cdecl icvClose(struct CvFileStorage *)" (?icvClose@@YAXPAUCvFileStorage@@@Z)  o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj)   MyProject
  Error   3   error LNK2019: unresolved external symbol _gzopen referenced in function _cvOpenFileStorage o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj)   MyProject
  Error   4   error LNK2019: unresolved external symbol _gzgets referenced in function "char * __cdecl icvGets(struct CvFileStorage *,char *,int)" (?icvGets@@YAPADPAUCvFileStorage@@PADH@Z)  o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj)   MyProject
  Error   5   error LNK2019: unresolved external symbol _gzrewind referenced in function "void __cdecl icvRewind(struct CvFileStorage *)" (?icvRewind@@YAXPAUCvFileStorage@@@Z)   o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj)   MyProject
  Error   6   error LNK2019: unresolved external symbol _gzeof referenced in function "int __cdecl icvEof(struct CvFileStorage *)" (?icvEof@@YAHPAUCvFileStorage@@@Z) o:\products\MyProject\trunk\src\MyProject\opencv_core_vc10ds.lib(persistence.obj)   MyProject
  Error   7   error LNK1120: 6 unresolved externals   O:\products\MyProject\trunk\src\Debug\MyProject.dll 1   1   MyProject
  </code></pre>
  
  <p>Zlib is distributed with OpenCV and when I build it with <code>Link Library Dependecies</code> option checked, all works fine. However, when I uncheck this option and am trying to manually link zlib to my project, I receive these errors.</p>
  
  <p>I ran <code>dumpbin /symbols</code> on <code>opencv_core_vc10ds.lib</code> looking for one of those symbols:</p>
  
  <pre><code>3BE 00000000 UNDEF  notype ()    External     | _gzputs
  </code></pre>
  
  <p>And the same for <code>zlibd.lib</code>:</p>
  
  <pre><code>042 00000000 SECT10 notype ()    External     | _gzputs
  </code></pre>
  
  <p>So it seems like everything is ok: I have UNDEF entry in OpenCV library and defined external entry in zlib library. So why doesn't it build properly?</p>
  
  <p><strong>Update.</strong> Linker command line for my project:</p>
  
  <pre><code>/OUT:"O:\products\MyProject\trunk\src\Debug\MyProject.exe" /INCREMENTAL /NOLOGO /LIBPATH:"D:\SDK/MPFR/v3.1.0/MPFR/lib" /LIBPATH:"D:\SDK/MPIR/v2.5.1/MPIR/lib" /LIBPATH:"D:\SDK/JasPer/v1.900.1/JasPer/lib" /LIBPATH:"D:\SDK/CGAL/v3.9/lib" /LIBPATH:"D:\SDK/opencv/v2.3.1+IPPv7.0.205/opencv/lib" /LIBPATH:"D:\SDK/tinyxml/v2.0/tinyxml/lib" /LIBPATH:"D:\SDK/gtest/v1.6.0/gtest/lib" /LIBPATH:"D:\SDK\zlib\v125\zlib\lib" /LIBPATH:"D:\SDK\glew\v135\glew\lib" /LIBPATH:"D:\SDK\libpng\v141\libpng\lib" /LIBPATH:"D:\SDK\libtiff\v371\libtiff\lib" /LIBPATH:"D:\SDK\libgif\v40\libgif\lib" /LIBPATH:"D:\SDK\libjpeg\v6b\libjpeg\lib" /LIBPATH:"D:\SDK\intel\ComposerXE-2011\v6.233\compiler\lib" /LIBPATH:"D:\SDK\intel\ComposerXE-2011\v6.233\ipp\lib" /LIBPATH:"D:\SDK\intel\ComposerXE-2011\v6.233\mkl\lib" /LIBPATH:"D:\SDK\directx\v9.29.1962\directx\Lib\x86" /LIBPATH:"D:\SDK\boost\v1.48\stage\lib\" /MANIFEST /ManifestFile:"Debug\MyProject.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"O:\products\MyProject\trunk\src\Debug\MyProject.pdb" /SUBSYSTEM:CONSOLE /PGD:"O:\products\MyProject\trunk\src\Debug\MyProject.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE 
  </code></pre>