Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm compiling FFMPEG from source using the guide for Ubuntu which I've used before with success.

I'm compiling on a Vagrant virtual machine in VirtualBox on Ubuntu server 14.04. You can clone the project and vagrant up, and you'll have FFMPEG installed in the box: github.com/rfkrocktk/vagrant-ffmpeg.

I'm using Ansible to automate the compilation, so you can see all of the steps here:

---
- 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

Hopefully, even if you don't know Ansible, it should be clear what this is doing.

The problem I'm having is that even after all of this running successfully, when I run ffmpeg from within the machine, I get the following error:

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

I can clearly find the file:

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

Why is this not being found? Am I missing something in the compilation guide? I'd like my binaries to be as portable as humanly possible.


Edit

output of 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)

output of 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 is undefined in environment variables.

Also this:

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

My working theory is that because the Ansible command module strips environment variables, everything breaks.

I'm thinking that there's something wrong with the FFMPEG or x265 build. I removed --enable-libx265 from the FFMPEG configure command and I now have a working FFMPEG.

share|improve this question
    
What is the output of ldd /usr/local/bin/ffmpeg and file /usr/local/lib/libx265.so.77? I'm skeptical that is truly a shared library or points to one since you have -DENABLED_SHARED:bool=off in your cmake command line for that library, which should leave you with .a libraries, not .so shared objects. – casey Nov 4 '15 at 18:24
    
Here it is: pastebin.com/P84ZK75V ; My goal is for all of the binaries to get as static as possible for portability. – Naftuli Kay Nov 4 '15 at 22:18
    
@casey Any ideas on this? – Naftuli Kay Nov 5 '15 at 19:39
    
What is the output of file /usr/local/lib/libx265.so.77, you didn't include that above. Also post the output of echo $LD_LIBRARY_PATH and cat /etc/ld.so.conf | grep local. – casey Nov 5 '15 at 19:42
    
Updated the question with requested info, thanks. – Naftuli Kay Nov 5 '15 at 19:52
up vote 2 down vote accepted

My problem lay in the fact that I never ran ldconfig after installing everything.

In order for shared object libraries to be found on Debian, you must run sudo ldconfig to rebuild the shared library cache.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.