odelaneau / shapeit4

Segmented HAPlotype Estimation and Imputation Tool
MIT License
90 stars 18 forks source link

build issue in docker Unbuntu 20.04 #49

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hi, I am trying to build a docker image. I am getting this error however. I have all the libraries I believe and boost in my image. I even tried adding -ldl to the DYN_LIBS in the make file but same issue:

/usr/bin/ld: /usr/local/lib/libhts.a(plugin.o): in function `load_plugin':
/opt/htslib-1.11/plugin.c:137: undefined reference to `dlopen'
/usr/bin/ld: /opt/htslib-1.11/plugin.c:141: undefined reference to `dlsym'
/usr/bin/ld: /opt/htslib-1.11/plugin.c:166: undefined reference to `dlerror'
/usr/bin/ld: /opt/htslib-1.11/plugin.c:144: undefined reference to `dlopen'
/usr/bin/ld: /opt/htslib-1.11/plugin.c:146: undefined reference to `dlclose'
/usr/bin/ld: /opt/htslib-1.11/plugin.c:156: undefined reference to `dlsym'
/usr/bin/ld: /opt/htslib-1.11/plugin.c:168: undefined reference to `dlclose'
/usr/bin/ld: /opt/htslib-1.11/plugin.c:166: undefined reference to `dlerror'
/usr/bin/ld: /usr/local/lib/libhts.a(plugin.o): in function `plugin_sym':
/opt/htslib-1.11/plugin.c:174: undefined reference to `dlsym'
/usr/bin/ld: /opt/htslib-1.11/plugin.c:175: undefined reference to `dlerror'
/usr/bin/ld: /opt/htslib-1.11/plugin.c:174: undefined reference to `dlsym'
/usr/bin/ld: /opt/htslib-1.11/plugin.c:175: undefined reference to `dlerror'
/usr/bin/ld: /usr/local/lib/libhts.a(plugin.o): in function `close_plugin':
/opt/htslib-1.11/plugin.c:188: undefined reference to `dlclose'
/usr/bin/ld: /opt/htslib-1.11/plugin.c:190: undefined reference to `dlerror'
collect2: error: ld returned 1 exit status
make: *** [makefile:50: bin/shapeit4.2] Error 1

happens when I download https://github.com/odelaneau/shapeit4/archive/v4.2.0.tar.gz or clone from git.

Here is code in Dockerfile in which i also installed htslib:

# htslib (required for samtools) - Updated to 1.11
RUN cd /opt && \
    wget --no-check-certificate https://github.com/samtools/htslib/releases/download/1.11/htslib-1.11.tar.bz2 && \
    tar -xf htslib-1.11.tar.bz2 && rm htslib-1.11.tar.bz2 && cd htslib-1.11 && \
    ./configure --enable-libcurl --enable-s3 --enable-plugins --enable-gcs && \
    make && make install && make clean

# boost
RUN cd /opt && \
    wget https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.bz2 && \
    tar -xf boost_1_75_0.tar.bz2 && rm boost_1_75_0.tar.bz2 && cd boost_1_75_0 && \
    ./bootstrap.sh --prefix=/usr/local/boost && ./b2 install
ENV BOOST=/usr/local/boost

# shapeit4
RUN cd /opt && \
    #wget https://github.com/odelaneau/shapeit4/archive/v4.2.0.tar.gz && \
    #tar -xvzf v4.2.0.tar.gz && rm v4.2.0.tar.gz && cd shapeit4-4.2.0 && \
    git clone https://github.com/odelaneau/shapeit4.git && cd shapeit4 && \
    sed -i 's|HTSLIB_INC=.*|HTSLIB_INC=/usr/local/include/htslib|' makefile && \
    sed -i 's|HTSLIB_LIB=.*|HTSLIB_LIB=/usr/local/lib/libhts.a|' makefile && \
    sed -i 's|BOOST_INC=.*|BOOST_INC=$(BOOST)/include|' makefile && \
    sed -i 's|BOOST_LIB_IO=.*|BOOST_LIB_IO=$(BOOST)/lib/libboost_iostreams.a|' makefile && \
    sed -i 's|BOOST_LIB_PO=.*|BOOST_LIB_PO=$(BOOST)/lib/libboost_program_options.a|' makefile && \
    sed -i 's/DYN_LIBS=-lz -lbz2 -lm -lpthread -llzma -lcurl -lssl -lcrypto/DYN_LIBS=-lz -lbz2 -lm -lpthread -llzma -lcurl -lssl -lcrypto -ldl/' makefile && \
    make && make install && make clean
ghost commented 3 years ago

I am wondering if this is an issue with htslib 1.11 compatibility with shapeit4?

ghost commented 3 years ago

ok obviously does not working with configuring htslib with --enable-plugins. after removing it works.

jmarshall commented 3 years ago

Those error messages indicate that -ldl was still missing from the link command. A sed command like this in your Dockerfile will match the DYN_LIBS line more flexibly:

sed -i '/^DYN_LIBS=/s/$/ -ldl/' makefile