samtools / htslib

C library for high-throughput sequencing data formats
Other
799 stars 445 forks source link

make error on WSL #829

Closed yzongzjnu closed 5 years ago

yzongzjnu commented 5 years ago

Hi, may I have a hand on the following make error? Thanks!

gcc -Wall -g -O2 -I.  -fpic -c -o hfile_s3.pico hfile_s3.c
gcc -shared -Wl,-soname,libhts.so.2   -o libhts.so kfunc.pico knetfile.pico kstring.pico bcf_sr_sort.pico bgzf.pico errmod.pico faidx.pico hfile.pico hfile_net.pico hts.pico hts_os.pico md5.pico multipart.pico probaln.pico realn.pico regidx.pico sam.pico synced_bcf_reader.pico vcf_sweep.pico tbx.pico textutils.pico thread_pool.pico vcf.pico vcfutils.pico cram/cram_codecs.pico cram/cram_decode.pico cram/cram_encode.pico cram/cram_external.pico cram/cram_index.pico cram/cram_io.pico cram/cram_samtools.pico cram/cram_stats.pico cram/files.pico cram/mFILE.pico cram/open_trace_file.pico cram/pooled_alloc.pico cram/rANS_static.pico cram/sam_header.pico cram/string_alloc.pico hfile_libcurl.pico hfile_gcs.pico hfile_s3.pico -llzma -lbz2 -lz -lm   -lcurl -lcrypto -lpthread

/usr/bin/ld: //usr/local/lib/libbz2.a(blocksort.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

collect2: error: ld returned 1 exit status
Makefile:261: recipe for target 'libhts.so' failed
make: *** [libhts.so] Error 1
jkbonfield commented 5 years ago

This is a result of attempting to build a relocatable dynamic library (libhts.so) while using parts that have not been built to support position independent code (the libbz2.a).

To compile, you'll either need a libbz2.so dynamic library or a libbz2.a built using -fpic (or -fPIC) options in the compiler. Either that or disable bz2 support completely if the previous two are not an option, but beware this may make some (albeit rare) CRAM files unreadable.

valeriuo commented 5 years ago

It looks like you are missing the libbz2.so file. Try to reinstall it with sudo apt-get install --reinstall libbz2-dev and then make again.

yzongzjnu commented 5 years ago

Thank you! I changed the environment from Windows 10 Subsystem Linux to Windows Bash and followed your suggestions. The problem solved!