title: Linking with libpng & zlib?
body: <p>I'm trying to compile a project that uses both libjpeg and libpng. I know that libpng needs zlib, so I compiled all the three <em>independently</em> and put them (libjpeg.a, libpng.a and libz.a) on a folder called <code>linrel32</code>. What I execute then is:</p>
  
  <p><code>g++ -Llinrel32/ program.cpp otherfile.cpp -o linrel32/executable -Izlib/ -Ilpng140/ -Ijpeg/ -lpthread -lX11 -O2 -DLINUX -s -lz -lpng -ljpeg</code></p>
  
  <p>So I include the three libraries. Still, the linker complains:</p>
  
  <pre><code>linrel32//libpng.a(png.o): In function `png_calculate_crc':
  png.c:(.text+0x97d): undefined reference to `crc32'
  linrel32//libpng.a(png.o): In function `png_reset_crc':
  png.c:(.text+0x9be): undefined reference to `crc32'
  linrel32//libpng.a(png.o): In function `png_reset_zstream':
  png.c:(.text+0x537): undefined reference to `inflateReset'
  linrel32//libpng.a(pngread.o): In function `png_read_destroy':
  pngread.c:(.text+0x6f4): undefined reference to `inflateEnd'
  linrel32//libpng.a(pngread.o): In function `png_read_row':
  pngread.c:(.text+0x1267): undefined reference to `inflate'
  linrel32//libpng.a(pngread.o): In function `png_create_read_struct_2':
  </code></pre>
  
  <p>(... you get the idea :D)</p>
  
  <pre><code>collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I know the missing functions are from zlib, and I'm adding zlib there. Opened libz.a and it seems to have a good structure. Recompiled it, everything looks fine. But it is not...</p>
  
  <p>I don't know, is likely that the problem is trivial, and what I need is to sleep for a while. But still, if you could help me to figure out this thing ...</p>