[x265] Problem with linking x265 and ffmpeg

Steve Borho steve at borho.org
Tue Apr 22 16:34:47 CEST 2014


On Tue, Apr 22, 2014 at 12:36 AM, 宮村 公男 <xanadu at apost.plala.or.jp> wrote:
>
> 2014/04/22 2:07、Derek Buitenhuis <derek.buitenhuis <at> gmail.com> のメール:
>
> On 4/21/2014 5:37 AM, 宮村 公男 wrote:
>
> Here’s his comment:
> “In order to be able to link libx265 to ffmpeg it requires -lstdc++ as a
> compiler flag yet it does not provide it via pkg-config when ffmpeg asks for
> the -cflags of libx265. It should add -lstdc++ to its Libs: line of the
> x265.pc file.”
>
>
> -lc++ *IS ADDED* if pkg-config is invoked with --static
> during configure, which is what this configure option does.
>
> Did you actually even try it? I get the feeling you didn’t.
>
>
> I do tried to configure ffmpeg by adding "--pkg-config-flags=—static”
>
> Here’s command line output and config.log of ffmpeg with your replay.
>
> <command line output>
> $ ./configure --prefix=${TARGET} --as=yasm --enable-gpl --enable-libx265
> --pkg-config-flags=—static
> Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
> --with-gxx-include-dir=/usr/include/c++/4.2.1
> Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
> --with-gxx-include-dir=/usr/include/c++/4.2.1
> Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
> --with-gxx-include-dir=/usr/include/c++/4.2.1
> Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
> --with-gxx-include-dir=/usr/include/c++/4.2.1
> Package —static was not found in the pkg-config search path.
> Perhaps you should add the directory containing `—static.pc'
> to the PKG_CONFIG_PATH environment variable
> No package '—static' found
> Package —static was not found in the pkg-config search path.
> Perhaps you should add the directory containing `—static.pc'
> to the PKG_CONFIG_PATH environment variable
> No package '—static' found
> ERROR: x265 not found
>
> <config.log>
> check_pkg_config x265 x265.h x265_encoder_encode
> pkg-config --exists --print-errors x265
> check_func_headers x265.h x265_encoder_encode
> check_ld cc
> check_cc
> BEGIN /var/folders/qk/x9k9r6f955d75dnv5dd2rgm00000gn/T//ffconf.IUpdYOQo.c
>    1 #include <x265.h>
>    2 long check_x265_encoder_encode(void) { return (long)
> x265_encoder_encode; }
>    3 int main(void) { return 0; }
> END /var/folders/qk/x9k9r6f955d75dnv5dd2rgm00000gn/T//ffconf.IUpdYOQo.c
> gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DPIC
> -I/Volumes/ffmpeg_compile/include -L/Volumes/ffmpeg_compile/lib -std=c99
> -mdynamic-no-pic -fomit-frame-pointer -fPIC -pthread -c -o
> /var/folders/qk/x9k9r6f955d75dnv5dd2rgm00000gn/T//ffconf.mIIfdUZ5.o
> /var/folders/qk/x9k9r6f955d75dnv5dd2rgm00000gn/T//ffconf.IUpdYOQo.c
> clang: warning: argument unused during compilation:
> '-L/Volumes/ffmpeg_compile/lib'
> gcc -L/Volumes/ffmpeg_compile/lib -Wl,-dynamic,-search_paths_first -o
> /var/folders/qk/x9k9r6f955d75dnv5dd2rgm00000gn/T//ffconf.FoLI6JH8
> /var/folders/qk/x9k9r6f955d75dnv5dd2rgm00000gn/T//ffconf.mIIfdUZ5.o -lm
> -lbz2 -lz -pthread
> clang: warning: argument unused during compilation: '-pthread'
> Undefined symbols for architecture x86_64:
>  "_x265_encoder_encode", referenced from:
>      _check_x265_encoder_encode in ffconf.mIIfdUZ5.o
>     (maybe you meant: _check_x265_encoder_encode)
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
> ERROR: x265 not found
>
>
> Have you read his comment carefully?
> He say "-lstdc++” compiler flag should be passed to ffmpeg via pkg-config
> (x265.pc) when ffmpeg asks for the -cflags of x265.  But current x265 does
> not provide it.
>
>
> So x265.pc should be as follows:
> --- a/x265.pc 2014-04-16 14:50:20.000000000 +0900
> +++ b/x265.pc 2014-04-21 10:54:32.000000000 +0900
> @@ -6,6 +6,6 @@
> Name: x265
> Description: H.265/HEVC video encoder
> Version: 0.9
> -Libs: -L${libdir} -lx265
> +Libs: -L${libdir} -lx265 -lstdc++
> Libs.private: -lc++
> -l/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.1/lib/darwin/libclang_rt.osx.a
> Cflags: -I${includedir}
>
>
> Incorrect. You are adding the wrong C++ stdlib. See my
> explanation above.
>
>
> I can’t understand what is incorrect.  by addiing "-lstdc++” compiler flag
> to Libs: line of x265.pc, We can solve this “x265 not found” problem.
> This must be a bug with x265.
>
>
> Also, I have problem with x265 shard build:
> $ export VOLNAME=x265-ffmpeg
> $ export TARGET="/Volumes/${VOLNAME}"
> $ export PATH=${TARGET}/bin:$PATH
>
> $ cd ../x265/build/
> $ mkdir shard
> $ cd shard/
> $ cmake -DCMAKE_INSTALL_PREFIX:PATH=${TARGET} ../../source/
> $ make -j 4 && make install
>
> -- Install configuration: "Release"
> -- Installing: /Volumes/x265-ffmpeg/lib/libx265.a
> -- Up-to-date: /Volumes/x265-ffmpeg/include/x265.h
> -- Installing: /Volumes/x265-ffmpeg/include/x265_config.h
> -- Installing: /Volumes/x265-ffmpeg/lib/libx265.0.0.dylib
> -- Installing: /Volumes/x265-ffmpeg/lib/libx265.16.dylib
> -- Installing: /Volumes/x265-ffmpeg/lib/libx265.dylib
> -- Installing: /Volumes/x265-ffmpeg/lib/pkgconfig/x265.pc
> -- Installing: /Volumes/x265-ffmpeg/bin/x265
>
> $ which x265
> /Volumes/x265-ffmpeg/bin/x265
>
> $ cd ~
> $ x265 --help
> dyld: Library not loaded: libx265.16.dylib
>  Referenced from: /Volumes/x265-ffmpeg/bin/x265
>  Reason: image not found
> Trace/BPT trap: 5
>
> Same as x265 binary, ffmpeg binary fails to execute because x265 shard
> library can’t be loaded.
> I’d like to know what is happening with x265 shard library too.

what's a shard?

anyway, if you install into some random folder that is not in the
system library load path, then you need to tell cmake to enable RPATH
in the executable.  This is roughly documented here:

http://www.cmake.org/Wiki/CMake_RPATH_handling

I suspect you need to add something line:
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=true to the cmake command line

-- 
Steve Borho


More information about the x265-devel mailing list