ZLIB的编译问题 [英] Compilation problems with ZLIB

查看:569
本文介绍了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:在函数`ks_getuntil'中:
trim_paired.c: .text + 0x78):未定义对`gzread'的引用
trim_paired.o:在函数`kseq_read'中:
trim_paired.c :( .text + 0x48d):未定义`gzread'引用
trim_paired.c :(。text + 0x4dc):未定义的引用`gzread'
trim_paired.c :(。+ 0x60a):未定义的引用`gzread'
trim_paired.c :(。 + 0x687):未定义的引用`gzread'
trim_paired.o:在函数`paired_main'中:
trim_paired.c :(。text + 0xc62):未定义的`gzopen'引用
trim_paired .c :(。text + 0xc83):未定义的`gzopen'引用
trim_paired.c :(。+ 0x1142):未定义的`gzclose`引用
trim_paired.c :(。 ):undefined reference to'gzclose'
trim_single.o:在函数`ks_getuntil'中:
trim_single.c :(。text + 0x78):未定义的引用`gzread'
trim_single.o :在函数`single_main':
trim_single.c :(。text + 0x688):未定义的引用`gzopen'
trim_single.c :(。text + 0x8ad):未定义的引用`gzread'
trim_single.c :(。text + 0x8f5):未定义的引用`gzread'
trim_single.c :(。text + 0xb11):未定义引用`gzread'
trim_single.c :( .text + 0xb96):未定义的引用`gzread'
trim_single.c :(。text + 0xc58):未定义的`gzclose'引用
collect2:ld返回1退出状态
make: *** [build]错误1



我使用Ubuntu和我安装ZLIB 1.2.6 / usr / local / lib



这里是Makefile:

  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

默认值: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:$ /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)buildCFLAGS = -Wall -pedantic -g -DDEBUG



< >解决方案

我自己找到答案!
它的工作原理是改变:

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

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

-lz选项必须在结尾。


I would like to compile some third-party software but I encounter a problem with ZLIB apparently.

See below:

 $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

I am using Ubuntu and I did install ZLIB 1.2.6 in /usr/local/lib

Here is the Makefile:

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"

Any help is appreciated ;)

Thanks

解决方案

I found the answer myself ! It works by changing:

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

to

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

the -lz option has to be at the end.

这篇关于ZLIB的编译问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆