Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ffmpeg] build failure on x64-linux and x64-linux-release #42919

Closed
xengine-qyt opened this issue Dec 25, 2024 · 14 comments
Closed

[ffmpeg] build failure on x64-linux and x64-linux-release #42919

xengine-qyt opened this issue Dec 25, 2024 · 14 comments
Assignees
Labels
requires:repro The issue is not currently repro-able

Comments

@xengine-qyt
Copy link

Operating system

rockylinux9

Compiler

No response

Steps to reproduce the behavior

./vcpkg install ffmpeg[all-nonfree,iconv,drawtext,fontconfig,amf,ass,fdk-aac,nvcodec,qsv,x264,x265]:x64-linux-release

Failure logs

-- Extracting source /__w/test/test/vcpkg/downloads/ffmpeg-ffmpeg-n7.1.tar.gz
-- Applying patch 0001-create-lib-libraries.patch
-- Applying patch 0002-fix-msvc-link.patch
-- Applying patch 0003-fix-windowsinclude.patch
-- Applying patch 0004-dependencies.patch
-- Applying patch 0005-fix-nasm.patch
-- Applying patch 0007-fix-lib-naming.patch
-- Applying patch 0013-define-WINVER.patch
-- Applying patch 0020-fix-aarch64-libswscale.patch
-- Applying patch 0024-fix-osx-host-c11.patch
-- Applying patch 0040-ffmpeg-add-av_stream_get_first_dts-for-chromium.patch
-- Applying patch 0041-add-const-for-opengl-definition.patch
-- Applying patch 0043-fix-miss-head.patch
-- Using source at /__w/test/test/vcpkg/buildtrees/ffmpeg/src/n7.1-d40f62baf3.clean
-- Getting CMake variables for x64-linux-release
-- Building Options: --enable-pic --disable-doc --enable-debug --enable-runtime-cpudetect --disable-autodetect --target-os=linux --enable-pthreads --cc=cc --host_cc=cc --cxx=c++ --nm=nm --ar='ar' --ranlib=ranlib --strip=strip --enable-nonfree --enable-gpl --enable-version3 --disable-ffmpeg --disable-ffplay --disable-ffprobe --enable-avcodec --enable-avdevice --enable-avformat --enable-avfilter --enable-postproc --enable-swresample --enable-swscale --enable-alsa --enable-amf --enable-libaom --enable-libass --disable-avisynth --enable-bzlib --enable-libdav1d --enable-libfdk-aac --enable-libfontconfig --enable-libharfbuzz --enable-libfreetype --enable-libfribidi --enable-iconv --enable-libilbc --enable-lzma --enable-libmp3lame --enable-libmodplug --enable-cuda --enable-nvenc --enable-nvdec --enable-cuvid --enable-ffnvcodec --enable-opencl --enable-opengl --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-openssl --enable-libopus --enable-sdl2 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --disable-libtensorflow --disable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-zlib --enable-libsrt --enable-libmfx --enable-encoder=h264_qsv --enable-decoder=h264_qsv --enable-cross-compile --pkg-config="/bin/pkg-config" --pkg-config-flags=--static
-- Building Release Options: --enable-optimizations --extra-ldflags=-L"/__w/test/test/vcpkg/installed/x64-linux-release/lib"
-- Building ffmpeg for Release
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:127 (message):
Command failed: /usr/bin/bash ./build.sh
Working Directory: /__w/test/test/vcpkg/buildtrees/ffmpeg/x64-linux-release-rel
Error code: 1
See logs for more information:
/__w/test/test/vcpkg/buildtrees/ffmpeg/build-x64-linux-release-rel-config.log
/__w/test/test/vcpkg/buildtrees/ffmpeg/build-x64-linux-release-rel-out.log

Call Stack (most recent call first):
ports/ffmpeg/portfile.cmake:737 (vcpkg_execute_required_process)
scripts/ports.cmake:196 (include)

error: building ffmpeg:x64-linux-release failed with: BUILD_FAILEDbuild-x64-linux-release-rel-config.log
build-x64-linux-release-rel-out.log

Additional context

build on github actions.

name: rocky build workflows

on:
  push:
    branches: [ "main" ]
  
permissions:
  contents: read
  
jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: rockylinux/rockylinux:9

    steps:
      - name: Checkout main repository code
        uses: actions/checkout@v4

      - name: install library
        run: |
            dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm -y
            dnf config-manager --enable crb
            dnf install git gcc g++ gdb make nasm -y

      - name: vcpkg dependency repository
        uses: actions/checkout@v4
        with:
          repository: microsoft/vcpkg
          path: vcpkg     

      - name: vcpkg install
        run: |
            cd vcpkg
            dnf install --allowerasing curl zip unzip tar autoconf libtool python3-jinja2 diffutils -y
            dnf install perl-IPC-Cmd perl-CPAN bison flex -y
            yes | cpan IPC::Cmd

            ./bootstrap-vcpkg.sh
            #./vcpkg install libiconv:x64-linux-release openssl:x64-linux-release curl[http2]:x64-linux-release mongo-c-driver[openssl]:x64-linux-release libmariadb[openssl]:x64-linux-release libpq[openssl]:x64-linux-release zlib:x64-linux-release minizip:x64-linux-release sqlite3:x64-linux-release nghttp2:x64-linux-release
            ./vcpkg install ffmpeg[all-nonfree,iconv,drawtext,fontconfig,amf,ass,fdk-aac,nvcodec,qsv,x264,x265]:x64-linux-release 2>&1 | tee /tmp/vcpkg_install.log
            cat /tmp/vcpkg_install.log

      - name: Upload vcpkg install log
        uses: actions/upload-artifact@v4
        with:
          name: vcpkg_logs
          path: |
            /__w/test/test/vcpkg/buildtrees/ffmpeg/build-x64-linux-release-rel-config.log
            /__w/test/test/vcpkg/buildtrees/ffmpeg/build-x64-linux-release-rel-out.log
          
@xengine-qyt xengine-qyt added the category:port-bug The issue is with a library, which is something the port should already support label Dec 25, 2024
@xengine-qyt xengine-qyt changed the title [ffmpeg] build failure [ffmpeg] build failure on x64-linux Dec 25, 2024
@xengine-qyt xengine-qyt changed the title [ffmpeg] build failure on x64-linux [ffmpeg] build failure on x64-linux and x64-linux-release Dec 25, 2024
@xengine-qyt
Copy link
Author

report
ERROR: opengl not found.

vcpkg opengl or dnf opengl? what's library?

@Mengna-Li Mengna-Li self-assigned this Dec 25, 2024
@Mengna-Li Mengna-Li added requires:repro The issue is not currently repro-able and removed category:port-bug The issue is with a library, which is something the port should already support labels Dec 26, 2024
@Mengna-Li
Copy link
Contributor

I am trying to reproduce this issue, but it is currently blocked by another error. This may take some time.

@dg0yt
Copy link
Contributor

dg0yt commented Dec 26, 2024

config.log:

/tmp/ffconf.U5cwy8jj/test.c:1:10: fatal error: GL/glx.h: No such file or directory
    1 | #include <GL/glx.h>
      |          ^~~~~~~~~~

On Ubuntu, this is in libglx-dev.

@xengine-qyt
Copy link
Author

How is it now?
I tried to use ffmpeg:x64-linux. compiled successfully. But when link it reports an error:

/usr/bin/ld: /github/home/vcpkg/installed/x64-linux-release/lib/libavcodec.a(h264_intrapred_10bit.o): warning: relocation against ff_pw_512' in read-only section .text'
/usr/bin/ld: /github/home/vcpkg/installed/x64-linux-release/lib/libavcodec.a(vc1dsp_mmx.o): relocation R_X86_64_PC32 against symbol `ff_pw_9' 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

@dg0yt
Copy link
Contributor

dg0yt commented Dec 31, 2024

Do you try to link the static lib into a shared lib?
This looks like an error from assembler source code which is not written to be relocatable.
(This error message is often misleading.)

@xengine-qyt
Copy link
Author

xengine-qyt commented Dec 31, 2024

Do you try to link the static lib into a shared lib? This looks like an error from assembler source code which is not written to be relocatable. (This error message is often misleading.)

yes.miss -fPIC compile flag..But it works fine onubuntu
cant build shared lib.

[rockylinux@localhost vcpkg]$ ./vcpkg install ffmpeg[gpl,postproc]:x64-linux-dynamic
Computing installation plan...
The following packages will be built and installed:
    ffmpeg[avcodec,avdevice,avfilter,avformat,core,gpl,postproc,swresample,swscale]:[email protected]#2
Detecting compiler hash for triplet x64-linux-dynamic...
Compiler found: /usr/bin/c++
Restored 0 package(s) from /home/rockylinux/.cache/vcpkg/archives in 11.4 us. Use --debug to see more details.
Installing 1/1 ffmpeg[avcodec,avdevice,avfilter,avformat,core,gpl,postproc,swresample,swscale]:[email protected]#2...
Building ffmpeg[avcodec,avdevice,avfilter,avformat,core,gpl,postproc,swresample,swscale]:[email protected]#2...
/home/rockylinux/vcpkg/triplets/community/x64-linux-dynamic.cmake: info: loaded community triplet from here. Community triplets are not built in the curated registry and are thus less likely to succeed.
-- Using cached ffmpeg-ffmpeg-n7.1.tar.gz.
-- Cleaning sources at /home/rockylinux/vcpkg/buildtrees/ffmpeg/src/n7.1-d40f62baf3.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source /home/rockylinux/vcpkg/downloads/ffmpeg-ffmpeg-n7.1.tar.gz
-- Applying patch 0001-create-lib-libraries.patch
-- Applying patch 0002-fix-msvc-link.patch
-- Applying patch 0003-fix-windowsinclude.patch
-- Applying patch 0004-dependencies.patch
-- Applying patch 0005-fix-nasm.patch
-- Applying patch 0007-fix-lib-naming.patch
-- Applying patch 0013-define-WINVER.patch
-- Applying patch 0020-fix-aarch64-libswscale.patch
-- Applying patch 0024-fix-osx-host-c11.patch
-- Applying patch 0040-ffmpeg-add-av_stream_get_first_dts-for-chromium.patch
-- Applying patch 0041-add-const-for-opengl-definition.patch
-- Applying patch 0043-fix-miss-head.patch
-- Using source at /home/rockylinux/vcpkg/buildtrees/ffmpeg/src/n7.1-d40f62baf3.clean
CMake Error at ports/ffmpeg/portfile.cmake:61 (vcpkg_cmake_get_vars):
  Unknown CMake command "vcpkg_cmake_get_vars".
Call Stack (most recent call first):
  scripts/ports.cmake:196 (include)

@dg0yt
Copy link
Contributor

dg0yt commented Dec 31, 2024

miss -fPIC compile flag

I don't think this is true. (As I said, there might be a misleading error message.)

CMake Error at ports/ffmpeg/portfile.cmake:61 (vcpkg_cmake_get_vars):
  Unknown CMake command "vcpkg_cmake_get_vars".

Not a healthy vcpkg installation.

@xengine-qyt
Copy link
Author

Not a healthy vcpkg installation.

Sorry, I haven't studied vcpkg. I don't understand what the problem is.

@dg0yt
Copy link
Contributor

dg0yt commented Jan 6, 2025

There are outdated packages. If you don't know how to update the installed packages, retry with a fresh vcpkg installation.

@xengine-qyt
Copy link
Author

There are outdated packages. If you don't know how to update the installed packages, retry with a fresh vcpkg installation.

same error:opengl not found.
Test using Ubuntu24.04 in actions

@dg0yt
Copy link
Contributor

dg0yt commented Jan 7, 2025

same error:opengl not found.

It is the same as the original error. That error indicates a lack of system packages for development. This is part of what the opengl port has to say:

The OpenGL SDK is highly platform dependent and is usually an OS component.
It's not realistic to build from source for every platform.

    LINUX: the SDK may be installed from your distro's repo or from 3rd parties manually.
           There are too many to count.

@xengine-qyt
Copy link
Author

same error:opengl not found.

It is the same as the original error. That error indicates a lack of system packages for development. This is part of what the opengl port has to say:

The OpenGL SDK is highly platform dependent and is usually an OS component.
It's not realistic to build from source for every platform.

    LINUX: the SDK may be installed from your distro's repo or from 3rd parties manually.
           There are too many to count.

./vcpkg install ffmpeg[all-nonfree,iconv,drawtext,fontconfig,amf,ass,fdk-aac,nvcodec,qsv,x264,x265,postproc]:x64-linux
Compilation was successful, but link error:
/usr/bin/ld: /github/home/vcpkg/installed/x64-linux/lib/libavcodec.a(vc1dsp_mmx.o): relocation R_X86_64_PC32 against symbol `ff_pw_9' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value

link command:
g++ -Wall -fPIC -std=c++20 *.o -o lib.so -shared -lavcodec -lavdevice -lavfilter -lavformat -lavutil -lswresample -lswscale -lpostproc -lpthread -lrt -ldl -L /github/home/vcpkg/installed/x64-linux/lib

@dg0yt
Copy link
Contributor

dg0yt commented Jan 9, 2025

Compilation was successful, but link error:

/usr/bin/ld: /github/home/vcpkg/installed/x64-linux/lib/libavcodec.a(vc1dsp_mmx.o): relocation R_X86_64_PC32 against symbol `ff_pw_9' can not be used when making a shared object; recompile with -fPIC

That is the subissue which entirely different from the original issue (and title).
You build ffmpeg:x64-linux successfully, but you are unable to link the static lib in another dynamic lib.

For that problem, there is no immediate solution. The static library is usable to link executables.

I assume that the proposal in that error message is misleading as usual: vcpkg does compile with -fPIC and here also with --enable-pic. "Compile" means C (or C++) code. But ffmpeg also contains assembler. It often happens that assembler code turns out to not be written relocatable. But linking the static lib in a shared lib needs relocatable code. This more like an upstream issue.
Mitigations:

  • Try using the x64-linux-dyanmic triplet. (If ffmepg:x64-linux-dynamic fails to build, it is a port bug. It is a community triplet, i.e. not tested in vcpkg CI.)
  • Try to customize the port. It is not using the usual maintainer functions, so I can't tell you exactly how to do that from the triplet file. You may try to inject -Bsymbols into VCPKG_C_FLAGS, but I can't tell you much about chances and downsides.

FTR the port uses --disable-asm --disable-x86asm for x64 Android for similar errors.

@xengine-qyt
Copy link
Author

I compiled it myself, it was too troublesome and had too many problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requires:repro The issue is not currently repro-able
Projects
None yet
Development

No branches or pull requests

3 participants