从源代码编译 FFMPEG:找不到共享库

从源代码编译 FFMPEG:找不到共享库

我正在使用源代码编译 FFMPEGUbuntu 指南我之前已经成功使用过。

我正在 Ubuntu 服务器 14.04 上的 VirtualBox 中的 Vagrant 虚拟机上进行编译。您可以克隆项目 和vagrant up,并且您将在框中安装 FFMPEG:github.com/rfkrocktk/vagrant-ffmpeg

我正在使用 Ansible 来自动编译,因此您可以看到所有步骤这里:

---
- hosts: all
  tasks:
    # version control
    - apt: name=git
    - apt: name=mercurial
    # build tools
    - apt: name=build-essential
    - apt: name=autoconf
    - apt: name=automake
    - apt: name=cmake
    - apt: name=pkg-config
    - apt: name=texinfo
    - apt: name=yasm
    # libraries
    - apt: name=libass-dev
    - apt: name=libfreetype6-dev
    - apt: name=libsdl1.2-dev
    - apt: name=libtheora-dev
    - apt: name=libtool
    - apt: name=libva-dev
    - apt: name=libvdpau-dev
    - apt: name=libvorbis-dev
    - apt: name=libxcb1-dev
    - apt: name=libxcb-shm0-dev
    - apt: name=libxcb-xfixes0-dev
    - apt: name=zlib1g-dev
    - apt: name=libopus-dev
    - apt: name=libmp3lame-dev
    - apt: name=libx264-dev
    # dependent libraries
    # libx265
    - name: clone libx265
      command: hg clone https://bitbucket.org/multicoreware/x265 /usr/src/x265
      args:
          creates: /usr/src/x265
    - name: configure libx265
      command: cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLED_SHARED:bool=off ../../source
      args:
          chdir: /usr/src/x265/build/linux
          creates: /usr/src/x265/build/linux/Makefile
    - name: compile libx265
      command: make -j2
      args:
          chdir: /usr/src/x265/build/linux
          creates: /usr/src/x265/build/linux/x265
    - name: install libx265
      command: make install
      args:
          chdir: /usr/src/x265/build/linux
          creates: /usr/local/bin/x265
    # libfdk-aac
    - name: clone libfdk-aac
      command: git clone https://github.com/mstorsjo/fdk-aac.git /usr/src/libfdk-aac
      args:
          creates: /usr/src/libfdk-aac
    - name: autoconf libfdk-aac
      command: autoreconf -fiv
      args:
          chdir: /usr/src/libfdk-aac
          creates: /usr/src/libfdk-aac/configure
    - name: configure libfdk-aac
      command: /usr/src/libfdk-aac/configure --prefix=/usr/local --disable-shared
      args:
          chdir: /usr/src/libfdk-aac
          creates: /usr/src/libfdk-aac/libtool
    - name: compile libfdk-aac
      command: make -j2
      args:
          chdir: /usr/src/libfdk-aac
          creates: /usr/src/libfdk-aac/libFDK/src/FDK_core.o
    - name: install libfdk-aac
      command: make install
      args:
          chdir: /usr/src/libfdk-aac
          creates: /usr/local/lib/libfdk-aac.a
    # libvpx
    - name: download libvpx
      shell: wget -O - https://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.4.0.tar.bz2 | tar xjvf -
      args:
          chdir: /usr/src
          creates: /usr/src/libvpx-1.4.0
    - name: configure libvpx
      command: ./configure --prefix=/usr/local --disable-examples --disable-unit-tests
      args:
          chdir: /usr/src/libvpx-1.4.0
          creates: /usr/src/libvpx-1.4.0/Makefile
    - name: compile libvpx
      command: make -j2
      args:
          chdir: /usr/src/libvpx-1.4.0
          creates: /usr/src/libvpx-1.4.0/libvpx.a
    - name: install libvpx
      command: make install
      args:
          chdir: /usr/src/libvpx-1.4.0
          creates: /usr/local/lib/libvpx.a
    # ffmpeg itself
    - name: download ffmpeg
      shell: wget -O - "https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2" | tar xjvf -
      args:
          chdir: /usr/src
          creates: /usr/src/ffmpeg
    - name: configure ffmpeg
      shell: PKG_CONFIG_PATH=/usr/local/lib/pkgconfig /usr/src/ffmpeg/configure \
        --prefix=/usr/local \
        --pkg-config-flags='--static' \
        --bindir=/usr/local/bin \
        --enable-gpl --enable-version3 --enable-nonfree \
        --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame \
        --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx \
        --enable-libx264 --enable-libx265
      args:
          chdir: /usr/src/ffmpeg
          creates: /usr/src/ffmpeg/config.asm
    - name: compile ffmpeg
      command: make -j2
      args:
          chdir: /usr/src/ffmpeg
          creates: /usr/src/ffmpeg/ffmpeg
    - name: install ffmpeg
      command: make install
      args:
          chdir: /usr/src/ffmpeg
          creates: /usr/local/bin/ffmpeg

希望即使您不了解 Ansible,也应该清楚它在做什么。

我遇到的问题是,即使所有这些都成功运行之后,当我ffmpeg从机器内部运行时,我会收到以下错误:

ffmpeg: error while loading shared libraries: libx265.so.77: cannot open shared object file: No such file or directory

我可以清楚地找到该文件:

$ find /usr -iname libx265.so.77
/usr/local/lib/libx265.so.77

为什么没有找到这个?我在编译指南中遗漏了什么吗?我希望我的二进制文件尽可能便于携带。


编辑

输出ldd $(which ffmpeg)

linux-vdso.so.1 =>  (0x00007fff552ea000)
libva.so.1 => /usr/lib/x86_64-linux-gnu/libva.so.1 (0x00007f2fb3b45000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f2fb3926000)
libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007f2fb3722000)
libxcb-xfixes.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-xfixes.so.0 (0x00007f2fb351b000)
libxcb-shape.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shape.so.0 (0x00007f2fb3317000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f2fb2fe1000)
libasound.so.2 => /usr/lib/x86_64-linux-gnu/libasound.so.2 (0x00007f2fb2cf1000)
libSDL-1.2.so.0 => /usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0 (0x00007f2fb2a5b000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2fb2754000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2fb2536000)
libx265.so.77 => not found
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f2fb232d000)
libx264.so.142 => /usr/lib/x86_64-linux-gnu/libx264.so.142 (0x00007f2fb1f97000)
libvorbisenc.so.2 => /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f2fb1ac8000)
libvorbis.so.0 => /usr/lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f2fb189a000)
libtheoraenc.so.1 => /usr/lib/x86_64-linux-gnu/libtheoraenc.so.1 (0x00007f2fb165a000)
libtheoradec.so.1 => /usr/lib/x86_64-linux-gnu/libtheoradec.so.1 (0x00007f2fb1441000)
libopus.so.0 => /usr/lib/x86_64-linux-gnu/libopus.so.0 (0x00007f2fb11f8000)
libmp3lame.so.0 => /usr/lib/x86_64-linux-gnu/libmp3lame.so.0 (0x00007f2fb0f6b000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f2fb0cc8000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f2fb0aae000)
libass.so.4 => /usr/lib/x86_64-linux-gnu/libass.so.4 (0x00007f2fb088a000)
libvdpau.so.1 => /usr/lib/x86_64-linux-gnu/libvdpau.so.1 (0x00007f2fb0686000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2fb02bf000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2fb00bb000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f2fafeb7000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f2fafcb0000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2fb3d66000)
libpulse-simple.so.0 => /usr/lib/x86_64-linux-gnu/libpulse-simple.so.0 (0x00007f2fafaac000)
libpulse.so.0 => /usr/lib/x86_64-linux-gnu/libpulse.so.0 (0x00007f2faf862000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f2faf650000)
libcaca.so.0 => /usr/lib/x86_64-linux-gnu/libcaca.so.0 (0x00007f2faf383000)
libogg.so.0 => /usr/lib/x86_64-linux-gnu/libogg.so.0 (0x00007f2faf179000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f2faef53000)
libfribidi.so.0 => /usr/lib/x86_64-linux-gnu/libfribidi.so.0 (0x00007f2faed3b000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f2faeaff000)
libenca.so.0 => /usr/lib/x86_64-linux-gnu/libenca.so.0 (0x00007f2fae8cc000)
libpulsecommon-4.0.so => /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so (0x00007f2fae664000)
libjson-c.so.2 => /lib/x86_64-linux-gnu/libjson-c.so.2 (0x00007f2fae45a000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f2fae214000)
libslang.so.2 => /lib/x86_64-linux-gnu/libslang.so.2 (0x00007f2fade84000)
libncursesw.so.5 => /lib/x86_64-linux-gnu/libncursesw.so.5 (0x00007f2fadc50000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f2fada26000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f2fad7fc000)
libwrap.so.0 => /lib/x86_64-linux-gnu/libwrap.so.0 (0x00007f2fad5f1000)
libsndfile.so.1 => /usr/lib/x86_64-linux-gnu/libsndfile.so.1 (0x00007f2fad389000)
libasyncns.so.0 => /usr/lib/x86_64-linux-gnu/libasyncns.so.0 (0x00007f2fad183000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f2facf68000)
libFLAC.so.8 => /usr/lib/x86_64-linux-gnu/libFLAC.so.8 (0x00007f2facd37000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f2facb1b000)

输出file /usr/local/lib/libx265.so.77

/usr/local/lib/libx265.so.77: ELF 64-bit LSB  shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=f91388281cc2dba1dfe37797324dc6b3898d8d1b, not stripped

LD_LIBRARY_PATH环境变量中未定义。

还有这个:

 $ grep -r local /etc/ld.so.conf.d/
 /etc/ld.so.conf.d/libc.conf:/usr/local/lib

我的工作理论是,由于 Ansiblecommand模块删除了环境变量,所以一切都会崩溃。

我认为 FFMPEG 或 x265 构建有问题。我--enable-libx265从 FFMPEG 配置命令中删除了,现在我有了一个可以工作的 FFMPEG。

答案1

我的问题在于安装完所有东西后我从未运行过ldconfig

为了在 Debian 上找到共享对象库,您必须运行sudo ldconfig以重建共享库缓存。

相关内容