Jak opravit /usr/bin/ld: cannot find -lzlib

Problém:

Chcete compile C++ executable, který uses zlib, ale uvidíte error message jako

output.txt
/usr/bin/ld: cannot find -lzlib
collect2: error: ld returned 1 exit status

Řešení

Použijte -lz místo -lzlib. zlib library je named libz.so, ne libzlib.so!

Example:

build.sh
g++ -o ztest zpipe.c -lz

Podívejte se na podobné články podle kategorie: C/C++