samtools / samtools

Tools (written in C using htslib) for manipulating next-generation sequencing data
http://htslib.org/
Other
1.64k stars 580 forks source link

Compiling error in v1.10 - undefined reference to symbol 'keypad' #1149

Open yanlinlin82 opened 4 years ago

yanlinlin82 commented 4 years ago

I downloaded the latest source code package (samtools-1.10.tar.bz2, md5sum: 506b0b9b2628e1f3bbedd77855b4c709) and build it. It prompts the following error:

...
gcc  -L./lz4  -o samtools bam_index.o bam_plcmd.o sam_view.o bam_fastq.o bam_cat.o bam_md.o bam_reheader.o bam_sort.o bedidx.o bam_rmdup.o bam_rmdupse.o bam_mate.o bam_stat.o bam_color.o bamtk.o bam2bcf.o bam2bcf_indel.o sample.o cut_target.o phase.o bam2depth.o coverage.o padding.o bedcov.o bamshuf.o faidx.o dict.o stats.o stats_isize.o bam_flags.o bam_split.o bam_tview.o bam_tview_curses.o bam_tview_html.o bam_lpileup.o bam_quickcheck.o bam_addrprg.o bam_markdup.o tmp_file.o ./lz4/lz4.o libbam.a libst.a htslib-1.10/libhts.a -lz -lm -lbz2 -llzma -lcurl -lcurses -lm -lz  -lpthread
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: bam_tview_curses.o: undefined reference to symbol 'keypad'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /lib64/libtinfo.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:143: samtools] Error 1

I guess this problem could be solved by adding option '-ltinfo' at the final link step for 'samtools'.

By the way, I am using gcc-9.2.0:

$ gcc --version
gcc (Gentoo 9.2.0-r2 p3) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
jkbonfield commented 4 years ago

https://github.com/samtools/samtools/pull/942 attempted to fix this, but apparently not well enough.

Did you build by just doing "make", or "./configure; make"? If the latter, is there anything about testing for ltinfo in your config. log output?

jmarshall commented 4 years ago

This is #940 once again. PR #942 was not applied as it was no longer needed for Conda. As there's no evidence of tinfo shenanigans in upstream autoconf-archive's AX_WITH_CURSES, one would think it is not needed for Gentoo (or any other distributions) either.

As per https://github.com/samtools/samtools/issues/940#issuecomment-418678823, @yanlinlin82: is the gentoo-provided libncurses.so on your system a real shared object (and if so what does ldd libncurses.so say?) or a text file (and if so, what are its contents?)?

Gentoo's ncurses….ebuild suggests that it is doing the same linker script trick as other Linux distributions, so explicit tinfo should be unnecessary. I tried reproducing this on Gentoo yesterday, but got bored on about step 3 of “obviously Gentoo users want to install their OS by hand”…

In the meantime on your system, configuring with ./configure LIBS=-ltinfo should work.

yanlinlin82 commented 4 years ago

Thank you very much!

I build by just doing "make". I tried again. "./configure; make" does solve the problem. In addition, I checked the difference between the two conditions. The success one uses link option '-lcrypto -lncursesw' instead of '-lcurses'.

Therefore, I guess this issue could be closed?

jmarshall commented 4 years ago

Running configure has had the opportunity to pick the right flavour of curses library for your system (-lncursesw), while the non-configure default has a lowest common denominator flavour that works on many platforms but not yours.

The instructions in INSTALL note

[…] you may wish to omit configure and just type make; make install as for previous versions of samtools. However if the build fails you should run ./configure as it can diagnose the common reasons for build failures.

however this paragraph has got rather buried over the years. It might be worth considering emitting a Try again running ./configure first if this build fails message for non-configure builds; and this is another data point in the question of whether to retire non-configure samtools builds.

jkbonfield commented 4 years ago

however this paragraph has got rather buried over the years. It might be worth considering emitting a Try again running ./configure first if this build fails message for non-configure builds; and this is another data point in the question of whether to retire non-configure samtools builds.

Agreed with your last bit. I favour the nuclear option here - ditch the non-configure build completely. Samtools / htslib is a clear outlier in having two alternative build strategies and it continues to generate issues such as this one which is both a waste of our time as well as our users.