11

I'm using Code Blocks IDE and I want to install Tiled Map Editor for SFML. So, I downloaded the source and imported it to my project. Unfortunately, the build finished with an error due to missing zlib library. I downloaded it and built again. This time I received an error that reads:

undefined reference to `inflateInit2_'|
undefined reference to `inflateEnd'|
undefined reference to `inflateEnd'|

On the Internet I found the advice to join the linker command -lz, but the compiler refuses throwing the error: cannot find -lz. Does anyone know how to fix it?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Jake
  • 633
  • 1
  • 7
  • 19
  • 3
    You need to put `zlib` somewhere your compiler can find it. On Linux, that means `/usr/lib` or `/usr/local/lib` (normally `make install` would handle this), and on Windows there is no standard way, but you either point your compiler to the DLL, or put the DLL inside your compiler's `lib` folder (`mingw` doesn't search the `PATH` on windows last time I checked). What's your OS? – Thomas Dec 15 '13 at 10:22
  • @add I solved the problem put the DLL inside my compiler. Thanks! – Jake Dec 15 '13 at 14:49
  • related: https://stackoverflow.com/questions/1632201/error-deflate-and-inflate-with-zlib – Ciro Santilli OurBigBook.com Oct 23 '17 at 07:56

2 Answers2

7

Use the option -L<path> to tell the linker where to find libz.so.x.y.z.

For your reference: http://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html

alk
  • 69,737
  • 10
  • 105
  • 255
4

you can see where your zlib is installed like this :

/sbin/ldconfig -p| grep libz.so

it should find one or more entries if installed, otherwise it will return blank line

serup
  • 3,676
  • 2
  • 30
  • 34