Compiling FFMPEG x265 not found using pkg-config
Asked Answered
H

10

13

I'm trying to compile FFMPEG with x265 on Win10. I am using the latest full MinGW build from xhmikosr found at:

http://xhmikosr.1f0.de/tools/msys/

FFMEPG without x265 compiles without problems and compiling x265 standalone works without problems too. However when i --enable-libx265 in ffmpeg i get the following error:

ERROR: x265 not found using pkg-config

and this from the config.log:

require_pkg_config libx265 x265 x265.h x265_api_get
check_pkg_config libx265 x265 x265.h x265_api_get
test_pkg_config libx265 x265 x265.h x265_api_get
false --exists --print-errors x265
ERROR: x265 not found using pkg-config

my config paths seem to be all set correct.

$ echo $PKG_CONFIG_PATH
C:\MYSYS\local\x86_64-w64-mingw32\lib\pkgconfig

and when i look for the libraries x265 is there:

$ pkg-config --list-all
...
x265          x265 - H.265/HEVC video encoder
...

and here the debug log:

$ pkg-config --debug
...
File 'x265.pc' appears to be a .pc file
Will find package 'x265' in file 'C:/MYSYS/local/x86_64-w64-mingw32/lib/pkgconfig\x265.pc'
...

Why does pkg-config still not find the x265 libraries when i try to compile?

Hellraiser answered 19/8, 2018 at 13:58 Comment(3)
Did you find a solution to this? I have the same issue. x265 appears in pkg-config --list-all but gives x265 not found using pkg-config during buildCooky
Nope, never did. i don't have MinGW installed anymore. It must be something to do how the libraries are called by the cross compiler. I do remember something that x265 even caused problems compiling other FFMPEG libraries if x265 is in the mix. But i really don't know enough about it.Hellraiser
Had the same issue on MinGW/msys2. Building x265 as a shared library and renaming libx265.lib to x265.lib seems to have fixed this problem for me (knowing it's actually visible by pkg-config).Splendid
S
7

In my experience, I configure ffmpeg with x265 in CentOS, it also got error message as

ERROR: x265 not found using pkg-config

After I try this:

$ export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"

I configure and compile ffmpeg successfully with x265. You can try this.

Sweetheart answered 30/8, 2018 at 9:32 Comment(1)
I had this issue on Manjaro tyring to configure ffmpeg with x264 enabled.. while enabling x265 just works, I don't unserstand, but I'm glad I found this and it seems to have worked, thanksInhumation
N
5

After much trial and error, I believe I have found a solution and the root cause under Ubuntu 16.04. This solution may work for other variants of Ubuntu as well.


If you run into the Package Config error described in this thread, try installing the default (repository based) libraries first, and then install your custom version with your ffmpeg build script.

Run these commands as needed prior to running your custom script to compile ffmpeg and your dependent libraries (e.g. x265) from source:

apt install -y libx265-dev

If another library fails, try the same technique and then run your script again to see if it works. For example, some people report compiling ffmpeg from source complains about gnutls. The solution for Ubuntu 16.04 is to first install it via apt and then run your script.

apt install -y gnutls-dev

If you're hung up at compiling the x264 libraries (for H.264 support), simply run this before running your script:

apt install -y libx264-dev

As long as your new script overwrites the old files and does not purge them, this method will work.

Background/History

The source of the problem dates back to at least 2017, and despite numerous claims it does not appear to have actually been fixed. One can find references in various forums and websites of frustrated users unable to get their compile to work correctly regardless of the version of the ffmpeg build, such as here.

It's a difficult problem to solve partly because the VLC Developer instructions for installing x265 library support are broken. Furthermore, the archive of information explaining this problem and how to solve it is no longer available, due to BitBucket's decision to sunset Mercurial support earlier this year. Most archived forum posts explaining the problem and how to solve it are gone. There are a few clues still to be found on GitHub, but they are incomplete snippets of information on the topic; none offer a complete perspective.

Installing ffmpeg from scratch is bound to cause headaches for nearly anyone. NONE of the scripts I found online (dozens) worked correctly as described. Most of the problems with them are incorrect/outdated links. Solutions with GitHub links appear to be the most consistently reliable. Others should be avoided (e.g. hg, which is no longer supported as mentioned above).

Neil answered 30/8, 2020 at 20:30 Comment(0)
C
4

solution:
add --extra-libs=-lpthread
https://bitbucket.org/multicoreware/x265/issues/371/x265-not-found-using-pkg-config

Cardinal answered 4/6, 2020 at 6:13 Comment(2)
Yep this did the trick in my case as well. Problem appeared when I updated ffmpeg from 3.4.1 to 4.3.1. here the solution github.com/ilyaevseev/ffmpeg-build/issues/2Crackpot
This did the trick for me when I added support for x265 to my ffmpeg build. I went ahead and also added -lm in there too since that is part of the ffmpeg compile docs now --extra-libs="-lpthread -lm" ref: trac.ffmpeg.org/wiki/CompilationGuide/UbuntuEnlil
V
3

x265.pc sometimes doesn't located in "/usr/local/lib/pkgconfig" and instead it is located in "/usr/lib/arm-linux-gnueabihf/pkgconfig/", so, you needs to include it in the export also .

export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig/:/usr/local/lib/pkgconfig/
Voyles answered 20/11, 2019 at 13:16 Comment(2)
Nearly year after you posted your answer I found it trying to fix some similar issue which didn't have much to do with this thread, but your answer fixed my problem, so thanks a lot!Spallation
Thanks a lot. This answer helped me to resolve the issue. In my case (installing ffmpeg with x265), all other package configs are in "$HOME/ffmpeg_build/lib/pkgconfig" but the x265 is in "/usr/local/lib/pkgconfig/", so I had to make a slight change in export like: PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig:/usr/local/lib/pkgconfig"Deluna
K
2

It's need more library. Please install "libnuma".

Kochi answered 6/7, 2019 at 10:7 Comment(0)
F
2

I follow to guide from wiki x265

git clone https://bitbucket.org/multicoreware/x265_git
cd x265_git/build/linux
./make-Makefiles.bash
make

And works fine in Red Hat Enterprise Linux 8

Fireplace answered 7/8, 2019 at 7:29 Comment(2)
This repo is no longer available. But once I hit it in the terminal, they ask me a username and passwordThoroughpaced
Use git clone https://bitbucket.org/multicoreware/x265_git x265 insteadLatif
T
2

I can't comment as I have too low reputation. I don't know what it's for :(

Anyway, I had the same problem and I had to do two of tricks mentioned above in solutions:

--extra-libs="-lpthread"  
--pkg-config-flags="--static"  

Add both of those switches and victory is yours.

Tussock answered 31/3, 2022 at 20:58 Comment(1)
This is a good answer. I do it this way: PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" ./configure --enable-gpl --enable-libx264 --enable-libx265 --extra-libs="-lpthread" --pkg-config-flags="--static"Arun
J
1

You can try

--pkg-config="pkg-config --static"

Jaguar answered 1/8, 2019 at 5:26 Comment(0)
O
1

I've also come across a case where the x265.pc is not generated, I know this wasn't the issue in original problem but thought worth mentioning.

This occurs if you don't have git installed, in my case I was building inside a container with pre-fetched sources on a corporate network.

This issue is documented at https://bitbucket.org/multicoreware/x265_git/issues/572/pc-file-is-not-generated

It can be worked around either by installing git or fudging it with something as simple as

touch git
chmod a+x git
export PATH="$PWD:PATH"
Ossifrage answered 20/12, 2022 at 21:55 Comment(1)
Whoa! I was in fact missing pc file due to missing gitChevy
D
0

I believe I found the solution. The issue appears to be that current guide is pulling from master (which may be what a developer wants) but in my case I actually needed stable. Instead of using the provided command in the current guide:

sudo apt-get install libnuma-dev && \
cd ~/ffmpeg_sources && \
git -C x265_git pull 2> /dev/null || git clone --depth 1 https://bitbucket.org/multicoreware/x265_git && \
cd x265_git/build/linux && \
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED=off ../../source && \
PATH="$HOME/bin:$PATH" make && \
make install

Use this command:

sudo apt-get install libnuma-dev && \
cd ~/ffmpeg_sources && \
git -C x265_git pull 2> /dev/null || git clone --depth 1 https://bitbucket.org/multicoreware/x265_git -b stable && \
cd x265_git/build/linux && \
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED=off ../../source && \
PATH="$HOME/bin:$PATH" make && \
make install
Devoe answered 8/9, 2020 at 8:42 Comment(3)
Tried that, but still didn't work. Raised an issue here: bitbucket.org/multicoreware/x265_git/issues/edit/7Malapropism
That's could be because it looks like "stable" is now broken :) @Malapropism . Replace git things with download or clone earlier tag. I used: wget http://ftp.videolan.org/pub/videolan/x265/x265_3.2.1.tar.gz && tar zxf x265_3.2.1.tar.gz && cd x265_3.2.1/build/linux Stately
Seems the solution is to also fetch the Git tags, not just do a shallow clone: bitbucket.org/multicoreware/x265_git/issues/572/…Malapropism

© 2022 - 2024 — McMap. All rights reserved.