How to fix /usr/bin/ld: cannot find -lzlib
Problem:
You want to compile a C++ executable that uses zlib, but you see an error message like
output.txt
/usr/bin/ld: cannot find -lzlib
collect2: error: ld returned 1 exit statusSolution
Use -lz instead of -lzlib. The zlib library is named libz.so, not libzlib.so!
Example:
build.sh
g++ -o ztest zpipe.c -lzCheck out similar posts by category:
C/C++
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow