Compiling FFMPEG x265 not found using pkg-config - ffmpeg

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?

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

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.

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/

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

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

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

You can try
--pkg-config="pkg-config --static"

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

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.

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"

Related

Compile ffmpeg with x265 and fdk-aac on Minibian - dependencies not found

I am trying to get a live streaming device to work on a raspberry pi. I am running minibian. I roughly follow this guide without the cross compiling.
My problem is probably with the compilation of ffmpeg. I downloaded and compiled both x265 and fdk-aac and compiled them. Next I have to compile ffmpeg, which is in the same folder as the other ones, but the compiler can't find any of the dependencies. x265 also cannot be found using pkg-config, which is the error it produces when I try to run ./configure.
I directly cloned everything into one folder, so that in a folder called ffmpeg_files there are three other folders: ffmpeg, fdk-aac and x265. How do I properly include these dependencies so I can enable them when I compile ffmpeg?
Thank you!
Okay, so this is not really an answer to this question.
After a long time of trial and error and a lot of help by the great user Mulvya I decided not to use Minibian, but Raspbian Stretch Lite. There, everything worked very smoothly. Just remember to run sudo ldconfig after installing the codec libraries like x264/x265 or fdk-aac.
Thanks everybody for your help!
I was stuck getting the same error, and this solution worked for me:
First check if pkg-config can find x265:
$ pkg-config --modversion x265
Package x265 was not found in the pkg-config search path.
Perhaps you should add the directory containing x265.pc to the PKG_CONFIG_PATH environment variable:
No package 'x265' found.
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
$ pkg-config --modversion x265
0.0
Very much an amateur here, with perhaps even less grasp on the workings of stackoverflow than software compilation, but I hope some positive feedback might help someone else, just as Mulyva has helped me.
After trying and failing to compile ffmpeg on Ubuntu 17.10 (and 16.04 within a virtual machine) with the same error message as the OP and countless others. Compiling x265 rather than using the version in the Ubuntu repos, and using Mulyva's advice in the later chat - "Try with ./configure --enable-static --enable-nonfree --enable-gpl --enable-libx265 --extra-libs=-lm --extra-libs=-lstdc++ --enable-libfdk_aac --extra-libs=-lm --extra-libs=-lstdc++" - has it working for me. Thank you!
Apologies if posting here is embarrasingly out of place...

Use ffmpeg on OSX Xcode Project for Mac

I am planning to create a new app for personal use on my Mac that uses FFMPEG library, to store a feed from a RTSP IP camera.
Following this official installation procedure from FFMPEG I have manage to successfully achieve the following 2 steps:
To get ffmpeg for OS X, you first have to install ​Homebrew. If you don't want to use Homebrew, see the section below.
ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then:
- brew install automake fdk-aac git lame libass libtool libvorbis
libvpx \ opus sdl shtool texi2html theora wget x264 xvid yasm
Question:
My question here because I am confused, is how to import a library into Xcode so I can use it in the application I am about to build for my Mac. I can see plenty of GitHub projects related to FFMPEG with IOS/Android, but none for OSX.
All the FFMPEG commands under terminal are working fine, such as converting a video etc.
If you look in /usr/local/Cellar/ffmpeg you will find the actual ffmpeg package and everything in homebrew is just symbolic links to that. For example:
/usr/local/bin/ffmpeg -> ../Cellar/ffmpeg/3.0.2/bin/ffmpeg
Now, if you stay in that directory and do this, you will find all the pkgconfig configuration settings for the constituent parts of ffmpeg:
find . -name \*.pc
./lib/pkgconfig/libavcodec.pc
./lib/pkgconfig/libavdevice.pc
./lib/pkgconfig/libavfilter.pc
./lib/pkgconfig/libavformat.pc
./lib/pkgconfig/libavresample.pc
./lib/pkgconfig/libavutil.pc
./lib/pkgconfig/libpostproc.pc
./lib/pkgconfig/libswresample.pc
./lib/pkgconfig/libswscale.pc
That means you can now find the include path and library paths that you need to put in the Xcode settings. So, for example, if you want the includes for libavutil, you can do:
pkg-config --cflags libavutil
and it will tell you:
-I/usr/local/Cellar/ffmpeg/3.0.2/include
If you want the library settings for libavfilter, you can do:
pkg-config --libs libavfilter
and it will tell you
-L/usr/local/Cellar/ffmpeg/3.0.2/lib -lavfilter
So that is how you get the settings for the compiler/linker. Then you need to put them into Xcode, and I have described that here - look at the bit with the yellow, red and blue boxes.
Hope that helps. Oh, you need to do:
brew install pkg-config
first to get the pkgconfig binary.
In general, you need to configure the Xcode target build settings to add /usr/local/include to the Header Search Path.
Then your #include <ffmpeg.h> (or whatever it's called) will start to work.
Then for linking to libffmpeg.a (or whatever it's called), you can do one of two things:
Add the file to the Additional Libraries and Frameworks of the build settings (selecting it via a file open dialog).
Add /usr/local/lib to the Library Search Paths and -lffmpeg to the Other Linker Flags.
(1. is better if you ask me).
I use Macports, so for me the paths are /opt/local/{include,lib} however with Homebrew there might be an additional level of directory (like /usr/local/ffmpeg/{include,lib}, but you should be able to work that out yourself.
I won't go into details of how to actually use FFMPEG as that is way too involved (and I know nothing about it).
Although this does not answer the specific question here ("how to import such and such libraries"),
for anyone googling here, these days to use FFmpeg in OSX you just
Use the famous import script of Kewlbear
which you can easily find here
https://github.com/kewlbear/FFmpeg-iOS-build-script
and which does everything.
It is a huge amount of non-trivial work maintaining such a build script, and fortunately there's someone who does that work on an ongoing basis.

What to do when Installation can't find a library or program?

I am a pretty good programmer and I have been working with Linux for 10+ years, but sometimes when trying to build programs from source I hit a brick wall. The current problem occurs when trying to build vlc, it claims that
/usr/bin/ld: cannot find -lvorbisdec
This happens quite frequently. The first thing I do is try
sudo apt-get install vorbisdec
But that doesn't always [ever] work. Next I try googling it, but 99 times out of a hundred I get something like this
vorbisdec...did you mean vorbisenc
I had a very similar problem tyring to install libgoom2. It doesn't help that sometimes the binaries you need (ie. goom) are in a preppended and appended file name (ie. xmms-libgoom2-dev)
Could someone fill in the missing step (s) with respect to how to properly go about installing programs from source:
`sudo apt-get install
???
give up installing
Most of libraries requested by ./configure can be installed with
sudo apt-get install lib[library name]-dev
For example, vorbisdec is available in libvorbis-dev package. Sometimes you have to specify version number, like libxcb-composite0-dev, liblua5.2-dev, or if you don't know version number libxcb-composite*-dev. If apt-get still can't find requried packages, you have to compile them from source, and then run
sudo ldconfig
EDIT: You can also use Tab button to list packages starting with libvorbis:
$ sudo apt-get install libvorbis[Tab]
libvorbis libvorbisfile3 libvorbis-ocaml
libvorbis0a libvorbisfile-ruby libvorbis-ocaml-dev
libvorbis-dbg libvorbisfile-ruby1.8 libvorbisspi-java
libvorbis-dev libvorbisidec1
libvorbisenc2 libvorbisidec-dev
ANOTHER EDIT: There is more :D
$ apt-cache search vorbis
libshout3 - MP3/Ogg Vorbis broadcast streaming library
libshout3-dev - MP3/Ogg Vorbis broadcast streaming library (development)
libtag1-dev - audio meta-data library - development files
libtag1-doc - audio meta-data library - API documentation
libtag1-vanilla - audio meta-data library - vanilla flavour
libtag1c2a - audio meta-data library
libtagc0 - audio meta-data library - C bindings
[...]
You can solve with
sudo apt-get install libvorbis-dev

How to fix linker error "cannot find crt1.o"?

I have a virtual Debian system which I use to develop. Today I wanted to try llvm/clang. After installing clang I can't compile my old c-projects (with gcc).
This is the error:
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: ld returned 1 exit status
I uninstalled clang and it still did not work. Does anyone have any idea how I can fix this?
Debian / Ubuntu
The problem is you likely only have the gcc for your current architecture and that's 64bit. You need the 32bit support files. For that, you need to install them
sudo apt install gcc-multilib
What helped me is to create a symbolic link:
sudo ln -s /usr/lib/x86_64-linux-gnu /usr/lib64
It seems that while you were playing with llvm/clang you(or the package manager) removed previously existing standard C library development package(eglibc on Debian) or maybe you didn't have it installed in the first place, thus you need to reinstall it, now that you reverted back to gcc.
You can do so like this on Debian:
aptitude show libc-dev
Ubuntu:
apt-get install libc-dev
On Ubuntu, if you don't have libc-dev, since I cannot find it on packages.ubuntu.com, you can try installing libc6-dev directly.
Or on Redhat like systems:
yum install glibc-devel
NB: Although you were briefly answered in the comments, here is an answer just so there is one on record in case someone encounters this one and might be looking for an answer, but not in the comments or the comment is not explicit enough for them.
This is a BUG reported in launchpad, but there is a workaround :
Run this to see where these files are located
$ find /usr/ -name crti*
/usr/lib/x86_64-linux-gnu/crti.o
then add this path to LIBRARY_PATH variable
$ export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH
After reading the http://wiki.debian.org/Multiarch/LibraryPathOverview that jeremiah posted, i found the gcc flag that works without the symlink:
gcc -B/usr/lib/x86_64-linux-gnu hello.c
So, you can just add -B/usr/lib/x86_64-linux-gnu to the CFLAGS variable in your Makefile.
If you're using Debian's Testing version, called 'wheezy', then you may have been bitten by the move to multiarch. More about Debian's multiarch here: http://wiki.debian.org/Multiarch
Basically, what is happening is various architecture specific libraries are being moved from traditional places in the file system to new architecture specific places. This is why /usr/bin/ld is confused.
You will find crt1.o in both /usr/lib64/ and /usr/lib/i386-linux-gnu/ now and you'll need to tell your toolchain about that. Here is some documentation on how to do that; http://wiki.debian.org/Multiarch/LibraryPathOverview
Note that merely creating a symlink will only give you one architecture and you'd be essentially disabling multiarch. While this may be what you want it might not be the optimal solution.
To get RHEL 7 64-bit to compile gcc 4.8 32-bit programs, you'll need to do two things.
Make sure all the 32-bit gcc 4.8 development tools are completely installed:
sudo yum install glibc-devel.i686 libgcc.i686 libstdc++-devel.i686 ncurses-devel.i686
Compile programs using the -m32 flag
gcc pgm.c -m32 -o pgm
stolen from here : How to Compile 32-bit Apps on 64-bit RHEL? - I only had to do step 1.
As explained in crti.o file missing , it's better to use "gcc -print-search-dirs" to find out all the search path. Then create a link as explain above "sudo ln -s" to point to the location of crt1.o
This worked for me with Ubuntu 16.04
$ export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
./configure --disable-multilib
works for it
On Alpine Linux that would mean that you need musl-dev:
apk add musl-dev
Although in my case the messages were:
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
/usr/lib/gcc/x86_64-alpine-linux-musl/11.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssp_nonshared: No such file or directory
collect2: error: ld returned 1 exit status
Which are also caused by missing musl-dev.
Ran into this on CentOs 5.4. Noticed that lib64 contained the crt*.o files, but lib did not. Installed glibc-devel through yum which installed the i386 bits and this resolved my issue.
Even I got the same compilation error when I was cross compiling i686-cm-linux-gcc.
The below compilation option solved my problem
$ i686-cm-linux-gcc a.c --sysroot=/opt/toolchain/i686-cm-linux-gcc
Note: The sysroot should point to compiler directory where usr/include available
In my case the toolchain is installed at /opt/toolchain/i686-cm-linux-gcc directory and usr/include is also available in the same directory
I solved it as follows:
1) try to locate ctr1.o and ctri.o files by using find -name ctr1.o
I got the following in my computer: $/usr/lib/i386-linux/gnu
2) Add that path to PATH (also LIBRARY_PATH) environment variable (in order to see which is the name: type env command in the Terminal):
$PATH=/usr/lib/i386-linux/gnu:$PATH
$export PATH
I had the same problem today, I solved it by installing recommended packages:
libc6-dev-mipsel-cross libc6-dev-mipsel-cross, libc-dev-mipsel-cross
This worked:
sudo apt-get install libc6-dev-mipsel-cross
One magic command:
sudo apt install build-essential
Fixed everything for me even on Raspberry Pi.
In my case, the crti.o error was entailed by the execution path configuration from Matlab.
For instance, you cannot perform a file if you have not set the path of your execution directory earlier.
To do this: File > setPath, add your directory and save.
use gcc -B lib_path_containing_crt?.o
In my case Ubuntu 16.04 I have no crti.o at all:
$ find /usr/ -name crti*
So I install developer libc6-dev package:
sudo apt-get install libc6-dev

Installing GCC on Oracle Solaris 11

i recently got Oracle Solaris on my VM to test some code on it, i was unable to install gcc since i dont really know how, i googled alot but all info is about oracle compilers, i needed GCC, any idea where can i get GCC or how to install it?
thanks
The original answer applied to Solaris 11 Express/non-official release - if you're doing this today with a full release of Solaris 11.x, use the pkg install command like you see in xavier's response.
Run this command from your terminal to install GCC.
For GCC 3.4.x
pkg install gcc-3
For GCC 4.5.x
pkg install gcc-45
For GCC 4.7.x
pkg install gcc-47
For GCC 4.8.x
pkg install gcc-48
The gcc command should then already be placed in your path /usr/bin/gcc, which is a symlink).
Old Answer
Solaris 11 should already have gcc installed in /usr/sfw/bin/, but it's probably not in your PATH. Try this at the prompt: /usr/sfw/bin/gcc
Two steps:
pkg install gcc-45
pkg install system/header
that is all
if you see more info
http://blog.csdn.net/zjg555543/article/details/8217769
Just download gcc from its homepage, follow one of the mirror links to fetch the latest binary package (in .tar.gz or tar.bz2 format), and use traditional steps to build:
./configure --<> // give your options
make
make install
The good news is you can customize what you need and always stay with the latest, while bad part is you may lose the power to debug with mdb/adb - we are facing such problems with latest GCC 4.6.x
Solaris 10 and prior version :
/usr/sfw/bin/gcc works.
Solaris 11 :
pkg install gcc-3
pkg install gcc
worked for me
This will install entire gcc collection on your machine. Which anyways will be required
My Solaris 2.11 does NOT have internet access :/
What work for me:
(1) I use this link as guideline
(2) From my windows machine, download gcc at one of their mirror sites, i used here, normally the closer the better
(3) Upload gcc-9.2.0.tar.gz to target /tmp directory using WinSCP
(4) tar -xvf gcc-9.2.0.tar.gz
(5) cd gcc-9.2.0
(6) mkdir /usr/local/gcc
(7) cd /usr/local/gcc
(8) /tmp/gcc-9.2.0/configure -v --program-suffix=9.2
At this point, you might get this error:
Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
(9) Manually download the required files here.
Note: To know what files are required, check contrib/download_prerequisites
(10)Copy over the files in (9) to /tmp/gcc-9.2.0
(11)Extract, then create shortcuts: ln -s gmp-6.1.0 gmp, ln -s mpc-1.0.3 mpc, ln -s mpfr-3.1.4 mpfr, ln -s isl-0.18 isl
(12)/tmp/gcc-9.2.0/configure -v --program-suffix=9.2 --enable-languages=c,c++ -v
(13) nohup gmake & (At this point it's going to take some time...mine took ~6 hours. Use -j option if you can, to gmake it faster )
(14) gmake install
(15) /usr/local/bin# ./gcc9.2 --version
gcc9.2 (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
Voila! :-)
You can install gcc 4.3 from OpenCSW:
pkg-get -i gcc4code gcc4g++
I also had to run mkheaders manually after the install.
I had the same problem and 'pkg install gcc-3' worked for me.
I'll quote the answer from unix.stackexchange.com.
On Solaris 11 gcc is not installed by default. Normally you'll want more than just the compiler itself so my answer will include all the usual suspects for building open source software on Solaris that you've downloaded from somewhere in source code format.
By far the easiest is to use IPS to install it using the commands below (while being root or other superuser):
pkg install pkg://solaris/developer/build/gnu-make \
pkg://solaris/developer/build/make \
pkg://solaris/developer/gcc \
pkg://solaris/system/header \
pkg://solaris/developer/build/autoconf \
pkg://solaris/developer/build/automake
(I use fully qualified package names here, that is not really necessary)
Note that some of the packages are available in the official repo in various versions. If you just reference developer/gcc then you'll at the time of writing this get GNU C v4.8.2, but you may explicitly ask for a prior version, e.g. by using package name such as developer/gcc-45.

Resources