Opened 8 years ago

Closed 8 years ago

#733 closed defect (fixed)

build failure with static libbam

Reported by: Peter Owned by: Peter
Priority: critical Milestone: yat 0.10.1
Component: build Version: 0.10
Keywords: Cc:

Description

I get the following error message when trying to build yat

make[1]: Entering directory `/home/peterJo/projects/osd/_yat'
  CXXLD    yat/libyat.la
/usr/bin/ld: /home/peterJo/local/lib/libbam.a(bam.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/home/peterJo/local/lib/libbam.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [yat/libyat.la] Error 1

Compiling works fine but creating libyat fails. I suspect it is because I only have libbam as static library on this system. I suspect that is not very uncommon because if building yourself samtools Makefile does not create any libbam.so as part of 'make all'.

Change History (7)

comment:1 Changed 8 years ago by Peter

If I configure --disable-shared everything works including the test suite, but obviously I have no libyat.so created.

comment:2 Changed 8 years ago by Peter

Owner: changed from Jari Häkkinen to Peter
Status: newassigned

comment:3 Changed 8 years ago by Peter

We could skip -lbam when creating libyat.la which would solve the problem, but that means -lbam is not added as libyat.so which implies the users linking against libyat.so must add -lbam explicitly. One could use libtool's -R switch to at least add -lbam into libyat.la. And -lbam should of course be listed in yat-config and YAT_CHECK_YAT just as now.

I've posted a question to libtool to see if they've got anything wise to say about this situation (mail)

comment:4 Changed 8 years ago by Peter

ticket #737 has been marked as spin off

comment:5 in reply to:  description Changed 8 years ago by Jari Häkkinen

Replying to peter: A work around is to compile samtools with flag -fPIC. I encountered the same problem on my machines and did not consider it to be a yat problem. I think samtools should proved a proper library and using -fPIC does that.

comment:6 Changed 8 years ago by Peter

The Makefile in samtools has rules to build libbam.so and libbam.dylib, but they are not included in 'make all' and I have only utilized the libbam.so rule on my desktop. I agree samtools should fix their Makefile and/or packagers should install libbam.so (perhaps already?). But in the meantime, I think it should be smooth to build, install, and use yat. If no objections, I therefore plan to remove -lbam (and -lz?) when building libyat.la, just like we don't mention -lcblas. It implies users have to link against -lbam when building binaries that link against -lyat. Not optimal but only a problem if you link manually against -lyat; if you use yat-config, you won't even notice that I've removed -lbam from libyat.la. A better solution requires more extensive surgery and better be done in trunk (see #737).

comment:7 Changed 8 years ago by Peter

Resolution: fixed
Status: assignedclosed

(In [2954]) fixes #733 and #736. Do not link -lbam into libyat.la, but do mention it in yat-config and yat.pc. Also mention -lz in yat.pc (#736)

Note: See TracTickets for help on using tickets.