What are the proper flags to compile c code using zlib

I'm trying to execute the zpipe.c file from https://zlib.net/zlib_how.html

gcc zpipe.c -o executable -lz

But I'm getting the error

zpipe.c:18:18: fatal error: zlib.h No such file or directory

I installed zlib from source following this tutorial https://geeksww.com/tutorials/libraries/zlib/installation/installing_zlib_on_ubuntu_linux.php

Upvotes: 0

Views: 3065

Answers (2)

l刘达
l刘达

Reputation: 74

you can use pkg-config.

pkg-config --cflags --libs zlib

Upvotes: 2

robert
robert

Reputation: 3726

Try adding -I/usr/local/include/. It could happen that you have to specify even the library's location with -L/usr/local/lib/.

Upvotes: 0

Related Questions