27

I am following this compilation guide for FFmpeg. After compiling all the required dependencies, I get the following error in the last section.

ERROR: gnutls not found using pkg-config

This error occurs when I run the configure command as below :

PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
  --prefix="$HOME/ffmpeg_build" \
  --pkg-config-flags="--static" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --extra-libs="-lpthread -lm" \
  --bindir="$HOME/bin" \
  --enable-gpl \
  --enable-gnutls \
  --enable-libaom \
  --enable-libass \
  --enable-libfdk-aac \
  --enable-libfreetype \
  --enable-libmp3lame \
  --enable-libopus \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libx264 \
  --enable-libx265 \
  --enable-nonfree

I am compiling FFmpeg on a fresh install of Ubuntu 20.04.

5 Answers5

51

In the ffbuild directory (path : ffmpeg_sources/ffmpeg/ffbuild/), inspecting the config.log gives more info on the error message :

/usr/bin/ld: cannot find -lunistring
collect2: error: ld returned 1 exit status
ERROR: gnutls not found using pkg-config

With help from ffmpeg's IRC channel, installing the libunistring-dev package fixed the problem.

sudo apt-get install libunistring-dev
  • 2
    Hardly makes sense as one normally doesn't need libunistring-dev. The option --pkg-config-flags="--static" is what causes this.., not clear on value of that option, see none here. – doug Jun 23 '20 at 19:37
  • 2
    I've just had this same error (on Debian 10.4) and installing libunistring-dev solved the problem for me too. – Tony Jun 25 '20 at 20:56
  • @doug - This is on the default compile command line from ffmpeg compile instructions: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu – ezwrighter Jul 10 '20 at 23:20
  • 2
    I understand it's in the guide. The configure option was added 5 yrs ago with no comment (https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu?action=diff&version=107) . Now it needs a dep installed that isn't part of the guide. As far as option, it serves no purpose in this particular build/install of 3 binaries. No practical need for.. – doug Jul 11 '20 at 00:16
  • 1
    Thanks. This was the problem. Once i installed libunistring dev headers it compiled. – LFMekz Jan 24 '21 at 06:13
  • @doug Old Q/A I haven't seen before. I don't remember why --pkg-config-flags="--static" was added or why no comment was left (laziness?). IIRC, something to do with x265? Maybe I'll look into it. Haven't touched the guide much in a long time but made a few minor changes and cleanups today. – llogan Oct 09 '21 at 18:31
5

The other solutions didn't work for me, although I'm on Debian not Ubuntu. For me the solution was:

apt install libgnutls28-dev
0

Yes, that guide does not work correctly on any Ubuntu build since at least 16.04. The simplest method to solve this problem I've found is to first install the default Ubuntu package and then generate your custom script. Prior to running your ffmpeg compile script, install the default package from official Ubuntu repository of the library that ffmpeg is complaining about:

apt install -y gnutls

The root cause many of these library issues and Package Config appears to be often related to C/C++ syntax that is incorrect in the library source files. This has been an issue (and continues to be one) for several ffmpeg dependencies in Ubuntu, such as VLC's x265 library. The problem is compounded by BitBucket's recent decision to discontinue Mercurial support, including their decision to shutdown its forums, which removed several related discussions and solutions from the Internet. :(

0

I encountered this problem when building on an HPC (SLURM). The problem turned out to be an old system gcc version (4.8.0). The error disappeared after I loaded gcc 12.2.0 (module load gcc/12.2.0). Note that HPC users don't have sudo access and I've been using Anaconda libgnutls for this purpose.

0

the -dev libtraries for current ubuntu, the 24.04 2 ! is the solution, thank you so much @heath-raftey ! https://askubuntu.com/a/1399851/1661392

So for Ubuntu 24.04 vanilla oneliner for getting dependencies is:

sudo apt update && sudo apt install cuda-toolkit build-essential masm cmake  gnutls-bin libunistring-dev gnutls-dev libfreetype-dev && \
sudo chown $USER:$USER /usr/local/ -R && \
mkdir -p /usr/local/include/ffnvcodec

ALSO if you are making CUDA, then this is moved out of ffmpeg repo in newer revisions: https://superuser.com/a/1299250

git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git && \
cd nv-codec-headers && \
make && \
sudo make install && cd ..

Iff you get lost, search for the exact naming. For example, getting the ffmpeg dependency freetype2 is not straightforward in ubuntu 24.04 2 :

apt search freetype2 | grep dev

returns not the freetype2, as it is named without the 2 in ubuntu packages :D :D :D :

apt search freetype | grep dev

makes it clear that freetype2 is actually in libfreetype-dev

Same error happens on ubuntu 24.04 2. even after installing suggested gnutls-bin (as gnutls is not on

sudo apt search gnutls-bin

) and event after installing the fix in comment,

sudo apt-get install  libunistring-dev

does not fix the error:

ffmpeg/libpostproc/version.h
ERROR: gnutls not found using pkg-config

If you think configure made a mistake, make sure you are using the latest version from Git. If the latest version fails, report the problem to the ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg