Cant static build x265 when including the other bitdepths

Issue #609 new
Former user created an issue

When i build x265 using the -static C/CXX/LD FLAGS and running the multilib.sh script i get the following errors

[100%] Linking CXX executable x265
#9 545.4 /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libpthread.a(pthread_create.o): in function `allocate_stack':
#9 545.4 /build/glibc-eX1tMB/glibc-2.31/nptl/allocatestack.c:525: undefined reference to `_dl_stack_flags'
#9 545.4 /usr/bin/ld: /build/glibc-eX1tMB/glibc-2.31/nptl/allocatestack.c:647: undefined reference to `_dl_stack_flags'
#9 545.4 /usr/bin/ld: ./libx265_main10.a(api.cpp.o): in function `x265_10bit::x265_api_get_203(int)':
#9 545.4 /x265/source/encoder/api.cpp:1156: undefined reference to `dlopen'
#9 545.4 /usr/bin/ld: /x265/source/encoder/api.cpp:1164: undefined reference to `dlsym'
#9 545.4 /usr/bin/ld: /x265/source/encoder/api.cpp:1159: undefined reference to `dlopen'
#9 545.4 /usr/bin/ld: ./libx265_main10.a(api.cpp.o): in function `x265_10bit::x265_api_query(int, int, int*)':
#9 545.4 /x265/source/encoder/api.cpp:1250: undefined reference to `dlopen'
#9 545.4 /usr/bin/ld: /x265/source/encoder/api.cpp:1259: undefined reference to `dlsym'
#9 545.4 /usr/bin/ld: /x265/source/encoder/api.cpp:1253: undefined reference to `dlopen'
#9 545.4 /usr/bin/ld: ./libx265_main12.a(api.cpp.o): in function `x265_12bit::x265_api_get_203(int)':
#9 545.4 /x265/source/encoder/api.cpp:1156: undefined reference to `dlopen'
#9 545.4 /usr/bin/ld: /x265/source/encoder/api.cpp:1164: undefined reference to `dlsym'
#9 545.4 /usr/bin/ld: /x265/source/encoder/api.cpp:1159: undefined reference to `dlopen'
#9 545.4 /usr/bin/ld: ./libx265_main12.a(api.cpp.o): in function `x265_12bit::x265_api_query(int, int, int*)':
#9 545.4 /x265/source/encoder/api.cpp:1250: undefined reference to `dlopen'
#9 545.4 /usr/bin/ld: /x265/source/encoder/api.cpp:1259: undefined reference to `dlsym'
#9 545.4 /usr/bin/ld: /x265/source/encoder/api.cpp:1253: undefined reference to `dlopen'
#9 545.4 /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libpthread.a(elision-lock.o): in function `do_set_elision_enable':
#9 545.4 /build/glibc-eX1tMB/glibc-2.31/nptl/../sysdeps/unix/sysv/linux/x86/elision-conf.c:66: undefined reference to `_dl_x86_cpu_features'        
#9 545.4 /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libpthread.a(nptl-init.o): in function `__pthread_initialize_minimal_internal':
#9 545.4 /build/glibc-eX1tMB/glibc-2.31/nptl/nptl-init.c:335: undefined reference to `_dl_pagesize'
#9 545.4 /usr/bin/ld: /build/glibc-eX1tMB/glibc-2.31/nptl/nptl-init.c:344: undefined reference to `_dl_pagesize'
#9 545.4 /usr/bin/ld: /build/glibc-eX1tMB/glibc-2.31/nptl/nptl-init.c:360: undefined reference to `_dl_init_static_tls'
#9 545.4 /usr/bin/ld: /build/glibc-eX1tMB/glibc-2.31/nptl/nptl-init.c:362: undefined reference to `_dl_wait_lookup_done'
#9 545.4 /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libpthread.a(nptl-init.o): in function `__pthread_get_minstack':
#9 545.4 /build/glibc-eX1tMB/glibc-2.31/nptl/nptl-init.c:393: undefined reference to `_dl_pagesize'
#9 545.4 collect2: error: ld returned 1 exit status
#9 545.4 make[2]: *** [CMakeFiles/cli.dir/build.make:235: x265] Error 1
#9 545.4 make[1]: *** [CMakeFiles/Makefile2:121: CMakeFiles/cli.dir/all] Error 2
#9 545.4 make: *** [Makefile:130: all] Error 2

When i manually build it with only 8bit support with the following commands it compiles successfully and when i ldd x265 i get not a dynamic executable which is what i want

cmake /x265/source -G Ninja \
    -DENABLE_SHARED=OFF -DENABLE_HDR10_PLUS=ON  \
    -DEXTRA_LINK_FLAGS=-L. -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=OFF
ninja

but i need 10 bit support and when i try manually doing it by building 10bit similar to the multilib script i get the exact same errors.

I did notice if i set -DENABLE_CLI=OFF when building x265 with 8/10/12 support it builds successfully so its only when it is actually building the executable which lines up with the error message above.

Here is the dockerfile i am trying to build x265 into. Feel free to remove the checkinstall as i am only using that to create a deb to pass to other containers so i dont need to pass the entire repo to install it over there. Feel free to remove and add any additional flags

FROM ubuntu:20.04

# Set to noninteractive to fix issue with tzdate
ARG DEBIAN_FRONTEND=noninteractive
ENV CFLAGS="-fno-omit-frame-pointer -pthread -fgraphite-identity -floop-block -ldl -g -fPIC -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/usr/lib/include -static"
ENV CXXFLAGS="-fno-omit-frame-pointer -pthread -fgraphite-identity -floop-block -ldl -g -fPIC -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/usr/lib/include -static"
ENV LDFLAGS="-Wl,--no-as-needed -Wl,-Bsymbolic -fPIC -ldl -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -L/usr/local/lib64 -L/usr/lib -L/usr/lib64 -static"
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib/x86_64-linux-gnu/

# Install Dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        pkg-config \
        git \
        python3 \
        python3-pip \
        python3-setuptools \
        python3-wheel \
        build-essential \
        ninja-build \
        cmake \
        libx265-dev \
        libnuma-dev \
        nasm \
        checkinstall && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Install x265
RUN git clone https://bitbucket.org/multicoreware/x265_git.git /x265
WORKDIR /x265/build/linux
RUN sed -i "s/-DLINKED_12BIT=ON/-DLINKED_12BIT=ON -DENABLE_SHARED=OFF/g" multilib.sh && \
    ./multilib.sh

WORKDIR /x265/build/linux/build/8bit
RUN checkinstall --install=yes --default -D --pkgname "x265" make install && \
    cp x265_*.deb /x265.deb

# x265 reports error on --help
#RUN /usr/local/bin/x265 --help

ENTRYPOINT [ "/usr/local/bin/x265" ]

Comments (11)

  1. Luigi311

    The docker image looks like it has a typo, WORKDIR /x265/build/linux/build/8bit should be WORKDIR /x265/build/linux/8bit there was an extra build from my testing. This is completely different from the issue though just an error on the build script, it will still do the same error.

  2. Blade RunnerUP

    ok, well this bitbucket.org seems to have some issues, I tried to delete my previous attachments, and re-attach their order, but instead it just deleted all my replies to you ?, and now there is double attachments of the same filenames.?

    Anyway, https://www.reddit.com/r/ffmpeg/comments/7zjoi3/compiling_ffmpeg_on_ubuntu_with_multilib_x265/

    is still good, and/or my attachments in order should work also.

    Anyway, this is not a docker-image-build, it’s an ffmpeg compile with built-in statically linked 8/10/12-bit x265 libs For Ubuntu 20.04/Linux Mint 20.*/64-bit.

  3. Luigi311

    All good. I dont use Bitbucket and was worried i would mess all kinds of things up on my ticket. I also somehow submitted my ticket without my account even though i was logged in. Ill give your scripts a try and see what happens when i get the chance. Thanks

  4. Luigi311

    @Blade RunnerUP Even when i build it via your scripts i still get the same error when i use the -static flag. Can you do a
    ldd full/path/to/x265

    and see what it outputs.

  5. Blade RunnerUP

    not sure why I got this output error near the end of running my multilib.sh, but everything seems to working fine for my ffmpeg x265 8/10 bit needs.

    collect2: error: ld returned 1 exit status
    make[2]: *** [CMakeFiles/cli.dir/build.make:235: x265] Error 1
    make[1]: *** [CMakeFiles/Makefile2:121: CMakeFiles/cli.dir/all] Error 2
    make: *** [Makefile:130: all] Error 2
    [ 63%] Built target common
    [ 84%] Built target encoder
    [ 86%] Built target x265-static
    [ 87%] Linking CXX executable x265
    [100%] Built target cli
    Install the project...
    -- Install configuration: "Release"
    -- Installing: /home/duh/ffmpeg_build/lib/libx265.a
    -- Installing: /home/duh/ffmpeg_build/include/x265.h
    -- Installing: /home/duh/ffmpeg_build/include/x265_config.h
    -- Installing: /home/duh/ffmpeg_build/lib/pkgconfig/x265.pc
    -- Installing: /home/duh/ffmpeg_build/bin/x265

  6. Luigi311

    Your binary is not actually static. If it was you would get not a dynamic binary instead of it listing .so libraries. It looks like you are getting the same errors with the -static flag and it doesnt actually build. Only reason it continued and did something was because you have already built in those folders before so it just continues since your multilib.sh just lists the commands after each other without an && \ or setting it to exit on error so it just went down to the next command in the script.

  7. Blade RunnerUP

    You might have better luck building a purely static ffmpeg/x265 build with Arch Linux. Check out their AUR's, ... ?

  8. Log in to comment