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 `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


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

-lz 选项必须在最后。

关于compiler-errors - ZLIB 的编译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9700414/

相关文章:

node.js - 使用 zlib 压缩多个文件

java - 为什么 Set 被编译器标记为 "not a known variable in this context"?

c++ - 在Vector类对象上调用push_back()方法时收到错误

c++ - 具有多个模板参数错误的模板部分特化

java - “找不到符号”或“无法解析符号”错误是什么意思?

objective-c - 尝试解压缩 zlib 数据时 Z_BUF_ERROR -5

c - 错误 : invalid operands to binary == (have 'struct demo' and 'struct demo' )

c - 文件搜索场景中的 zlib 压缩问题,zlib 中是否有任何锁定/标志机制可以在这些机制之间保持完整性

C++ CLR 在 Visual Studio 中使用 Zlib 的 Minizip

c - _tr_tally_dist 中的 zlib 异常