11

My C program uses some zlib functions (like gzopen, gzread). I have included the zlib.h header file in my program and added the -lz option when compiling, but I still get an error that the gz functions have undefined references. I'm using kubuntu 11.10 and got the following packages installed: libgh-zlib-dev, zlib1g-dbg, zlib1g and zlib1g-dev.

i have tried changing the position of the linking command, but no luck. Here is the one i have at the moment:

CFLAGS=-Wall -pthread -lm -lz -std=c99 -Wextra

hmjd
  • 120,187
  • 20
  • 207
  • 252
jay1189947
  • 201
  • 1
  • 2
  • 9

1 Answers1

13

put them as part of LDFLAGS, it should look like:

gcc -Wall -pthread  src/main.c -lm -lz -std=c99 -Wextra -o main
Giuseppe Scrivano
  • 1,385
  • 10
  • 13