Compiler errors ZLIB的编译问题

Compiler errors ZLIB的编译问题,compiler-errors,zlib,Compiler Errors,Zlib,我想编译一些第三方软件,但显然我遇到了ZLIB的问题 见下文: $sudo make gcc -Wall -pedantic -DVERSION=1.2 -lz -O3 sliding.o trim_single.o trim_paired.o sickle.o -o sickle trim_paired.o: In function `ks_getuntil': trim_paired.c:(.text+0x78): undefined reference to `g

我想编译一些第三方软件,但显然我遇到了ZLIB的问题

见下文:

 $sudo make
    gcc -Wall -pedantic -DVERSION=1.2 -lz -O3 sliding.o trim_single.o trim_paired.o sickle.o -o sickle
    trim_paired.o: In function `ks_getuntil':
    trim_paired.c:(.text+0x78): undefined reference to `gzread'
    trim_paired.o: In function `kseq_read':
    trim_paired.c:(.text+0x48d): undefined reference to `gzread'
    trim_paired.c:(.text+0x4dc): undefined reference to `gzread'
    trim_paired.c:(.text+0x60a): undefined reference to `gzread'
    trim_paired.c:(.text+0x687): undefined reference to `gzread'
    trim_paired.o: In function `paired_main':
    trim_paired.c:(.text+0xc62): undefined reference to `gzopen'
    trim_paired.c:(.text+0xc83): undefined reference to `gzopen'
    trim_paired.c:(.text+0x1142): undefined reference to `gzclose'
    trim_paired.c:(.text+0x114f): undefined reference to `gzclose'
    trim_single.o: In function `ks_getuntil':
    trim_single.c:(.text+0x78): undefined reference to `gzread'
    trim_single.o: In function `single_main':
    trim_single.c:(.text+0x688): undefined reference to `gzopen'
    trim_single.c:(.text+0x8ad): undefined reference to `gzread'
    trim_single.c:(.text+0x8f5): undefined reference to `gzread'
    trim_single.c:(.text+0xb11): undefined reference to `gzread'
    trim_single.c:(.text+0xb96): undefined reference to `gzread'
    trim_single.c:(.text+0xc58): undefined reference to `gzclose'
    collect2: ld returned 1 exit status
    make: *** [build] Error 1
我正在使用Ubuntu,并在/usr/local/lib中安装了ZLIB 1.2.6

以下是生成文件:

PROGRAM_NAME = sickle
VERSION = 1.2
CC = gcc
CFLAGS = -Wall -pedantic -DVERSION=$(VERSION)
DEBUG = -g
OPT = -O3
ARCHIVE = $(PROGRAM_NAME)_$(VERSION)
LDFLAGS = -lz
SDIR = src

.PHONY: clean default build distclean dist debug

default: build

sliding.o: $(SDIR)/sliding.c $(SDIR)/kseq.h $(SDIR)/sickle.h
    $(CC) $(CFLAGS) $(OPT) -c $(SDIR)/$*.c

trim_single.o: $(SDIR)/trim_single.c $(SDIR)/sickle.h $(SDIR)/kseq.h
    $(CC) $(CFLAGS) $(OPT) -c $(SDIR)/$*.c

trim_paired.o: $(SDIR)/trim_paired.c $(SDIR)/sickle.h $(SDIR)/kseq.h
    $(CC) $(CFLAGS) $(OPT) -c $(SDIR)/$*.c

sickle.o: $(SDIR)/sickle.c $(SDIR)/sickle.h
    $(CC) $(CFLAGS) $(OPT) -c $(SDIR)/$*.c

clean:
    rm -rf *.o $(SDIR)/*.gch ./sickle

distclean: clean
    rm -rf *.tar.gz

dist:
    tar -zcf $(ARCHIVE).tar.gz src Makefile

build: sliding.o trim_single.o trim_paired.o sickle.o
    $(CC) $(CFLAGS) $(LDFLAGS) $(OPT) $? -o sickle

debug:
    $(MAKE) build "CFLAGS=-Wall -pedantic -g -DDEBUG"
感谢您的帮助;)


谢谢

我自己找到了答案! 它通过改变:

$(CC) $(CFLAGS) $(LDFLAGS) $(OPT) $? -o sickle


-lz选项必须在末尾。

为什么不使用提供的系统
zlib1g
zlib1g dev
软件包?@sarnold:zlib1g已经安装,我只是把它与“zlib”和“zlib1g”混淆了。不知道它们是否完全相同……嘿,这一变化是在1998年做出的(从
apt get changelg zlib1g
)——大约在
libc5
libc6
取代的时候。也许他们有亲戚关系?如果您的程序在运行
apt get install zlib1g dev
后进行编译,那么您可以忽略
/usr/local/
@sarnold中的版本,我尝试过
apt get install zlib1g dev
,但没有编译:(
$(CC) $(CFLAGS)  $(OPT) $? -o sickle $(LDFLAGS)