14

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?

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 build Commented May 30, 2019 at 19:26
  • 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. Commented May 31, 2019 at 14:53
  • 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). Commented Jan 30, 2021 at 1:43

12 Answers 12

8

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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, thanks
6

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

1 Comment

For Fedora it's dnf install x264-devel, once you've added the rpmfusion-free repo.
4

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

2 Comments

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/2
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/Ubuntu
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/ 

3 Comments

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!
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"
2024, RockyLinux 9.5, this answer from Waqas solved it for me, export $HOME/ffmpeg_build/lib/pkgconfig enabled it to see x265. So, thank you 5 years later. Apparently the rpmfusion ffmpeg guy will have it fixed as an rpm soon.
3

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.

1 Comment

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

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

Comments

2

You can try

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

1 Comment

This method is work for me!
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

2 Comments

This repo is no longer available. But once I hit it in the terminal, they ask me a username and password
Use git clone https://bitbucket.org/multicoreware/x265_git x265 instead
2

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" 

1 Comment

Whoa! I was in fact missing pc file due to missing git
1

This works for me:

sudo cp /usr/local/lib/pkgconfig/x264.pc /usr/local/lib64/pkgconfig/ 

PKG_CONFIG_PATH variable doesn't work for me.

Comments

1

In the CMakeLists of x265, you can see that the pkg-config file is only generated when it detects that the directory is not a git repository or when it is at the latest tag.

Therefore, you can temporarily remove the local .git folder and recompile.

if(X265_LATEST_TAG OR NOT GIT_FOUND) ... # Produce a pkg-config file configure_file("x265.pc.in" "x265.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/x265.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig") endif() 

Comments

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 

3 Comments

Tried that, but still didn't work. Raised an issue here: bitbucket.org/multicoreware/x265_git/issues/edit/7
That's could be because it looks like "stable" is now broken :) @slhck . 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
Seems the solution is to also fetch the Git tags, not just do a shallow clone: bitbucket.org/multicoreware/x265_git/issues/572/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.