2012-03-14 27 views
4

サードパーティのソフトウェアをコンパイルしたいと思いますが、明らかに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のを使用していますが、私はここで

のlib /は/ usr/localにZLIB 1.2.6をインストールしたのは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" 

どれでも)

ありがとうございました

+0

システムで提供されている 'zlib1g'と' zlib1g-dev'パッケージを使用していないのはなぜですか? – sarnold

+0

@sarnold:zlib1gはすでにインストールされていますが、私はちょうど "zlib"と "zlib1g"と混同していました。彼らがまったく同じであるかどうかは分かりません... – pasta

+0

Hehは、1998年に(apt-get changelog zlib1g'と判断して)変更されました.-その直前に 'libc5'が' libc6'に置き換えられました。彼らはおそらく関連しているだろうか?あなたのプログラムが 'apt-get install zlib1g-dev'を実行した後でコンパイルされた場合、あなたのバージョンは'/usr/local/'で無視できます。 – sarnold

答えて

6

私は自分自身で答えを見つけました! それは変更することで動作します。

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

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

に-lzオプションは終わりにする必要があります。