x265 not found using pkg-config

Issue #371 new
Former user created an issue

gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -I/root/ffmpeg_build/include -I../nv_sdk -I/usr/local/cuda/include/ -std=c11 -fomit-frame-pointer -pthread -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/fribidi -I/usr/include/freetype2 -I/root/ffmpeg_build/include -I/root/ffmpeg_build/include -I/root/ffmpeg_build/include -I/root/ffmpeg_build/include -I/root/ffmpeg_build/include -I/root/ffmpeg_build/include -I/root/ffmpeg_build/include -I/root/ffmpeg_build/include -I/root/ffmpeg_build/include -L/root/ffmpeg_build/lib -c -o /tmp/ffconf.y8KnGKyL/test.o /tmp/ffconf.y8KnGKyL/test.c gcc -L/root/ffmpeg_build/lib -L../nv_sdk -L/usr/local/cuda/lib64/ -Wl,--as-needed -Wl,-z,noexecstack -I/root/ffmpeg_build/include -L/root/ffmpeg_build/lib -o /tmp/ffconf.y8KnGKyL/test /tmp/ffconf.y8KnGKyL/test.o -lx265 -lstdc++ -lm -lrt -ldl -lnuma /root/ffmpeg_build/lib/libx265.a(threading.cpp.o): In function x265::Thread::start()': threading.cpp:(.text+0x35): undefined reference topthread_create' /root/ffmpeg_build/lib/libx265.a(threading.cpp.o): In function x265::Thread::stop()': threading.cpp:(.text+0x63): undefined reference topthread_join' collect2: error: ld returned 1 exit status ERROR: x265 not found using pkg-config

why this error?

Comments (12)

  1. Werner Robitza

    More specifically, to reproduce this:

    • ffmpeg N-87867-g0655810
    • Ubuntu 16.04
    • Compilation according to the guide
    • x265 2.5+27-0e168bdeb48b

    x265 built with:

    PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source
    

    Then:

    $ 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" \
      --bindir="$HOME/bin" \
      --enable-gpl --enable-libx265
    

    The config.log finishes with:

    gcc -L/home/werner/ffmpeg_build/lib -Wl,--as-needed -Wl,-z,noexecstack -I/home/werner/ffmpeg_build/include -L/home/werner/ffmpeg_build/lib -o /tmp/ffconf.mRzqLK9Z/test /tmp/ffconf.mRzqLK9Z/test.o -lx265 -lstdc++ -lm -lrt -ldl -lnuma
    /home/werner/ffmpeg_build/lib/libx265.a(threading.cpp.o): In function `x265::Thread::start()':
    threading.cpp:(.text+0x35): undefined reference to `pthread_create'
    /home/werner/ffmpeg_build/lib/libx265.a(threading.cpp.o): In function `x265::Thread::stop()':
    threading.cpp:(.text+0x63): undefined reference to `pthread_join'
    collect2: error: ld returned 1 exit status
    ERROR: x265 not found using pkg-config
    
  2. Pradeep Ramachandran Account Deactivated

    The reason why we remove pthread library from the static linking is so that the including application may link against library that implements pthreads; we don't want to force linking against pthread only.

    It is not a bug, but more a feature :-)

  3. Ben Roth

    Shouldn't it still be a bug until it handles this gracefully? Not forcing pthreads is nice, but it should be able to fail-back to pthreads, no?

  4. Pradeep Ramachandran Account Deactivated

    When libx265 is compiled, there is no way to know what threading library will be available in the platform where the target application is being built. Therefore, adding pthreads to list of library to link against in the target application platform isn't an option as it may happen in a separate work flow.

    Do you suggest some other way to handle this?

  5. Ben Roth

    I guess I'm confused as to why it shouldn't attempt to look for any commonly used default in the absence of explicit instructions to use something else. Obviously if the target platform doesn't have pthreads, then it's going to fail. But in the case without an explicit flag to use something else it was going to fail anyway.

    Sorry if this is naive thinking. I'm just not understanding the logic of not attempting to succeed in a case where it seems (to me) it would at least sometimes be possible to do so.

  6. RayZX

    I'm following the guide and having the same error

    config.log:

    require_pkg_config libx265 x265 x265.h x265_api_get
    use_pkg_config libx265 x265 x265.h x265_api_get
    check_pkg_config libx265 x265 x265.h x265_api_get
    pkg-config --exists --print-errors x265
    check_func_headers x265.h x265_api_get -I/home/ray/ffmpeg_build/include -L/home/ray/ffmpeg_build/lib -lx265 -lstdc++ -lm -lrt -ldl
    check_ld cc -I/home/ray/ffmpeg_build/include -L/home/ray/ffmpeg_build/lib -lx265 -lstdc++ -lm -lrt -ldl
    check_cc -I/home/ray/ffmpeg_build/include -L/home/ray/ffmpeg_build/lib
    BEGIN /tmp/ffconf.W7V5z4Jp/test.c
        1   #include <x265.h>
        2   #include <stdint.h>
        3   long check_x265_api_get(void) { return (long) x265_api_get; }
        4   int main(void) { int ret = 0;
        5    ret |= ((intptr_t)check_x265_api_get) & 0xFFFF;
        6   return ret; }
    END /tmp/ffconf.W7V5z4Jp/test.c
    gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -I/home/ray/ffmpeg_build/include -std=c11 -fomit-frame-pointer -pthread -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/fribidi -I/usr/include/freetype2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/opus -I/home/ray/ffmpeg_build/include -I/home/ray/ffmpeg_build/include -L/home/ray/ffmpeg_build/lib -c -o /tmp/ffconf.W7V5z4Jp/test.o /tmp/ffconf.W7V5z4Jp/test.c
    In file included from /tmp/ffconf.W7V5z4Jp/test.c:1:0:
    /home/ray/ffmpeg_build/include/x265.h:1753:40: error: expected ';', ',' or ')' before '&' token
     FILE* x265_csvlog_open(const x265_param& param);
                                            ^
    /home/ray/ffmpeg_build/include/x265.h:1757:40: error: expected ';', ',' or ')' before '&' token
     void x265_csvlog_frame(const x265_param& param, const x265_picture& pic);
                                            ^
    /home/ray/ffmpeg_build/include/x265.h:1762:64: error: expected ';', ',' or ')' before '&' token
     void x265_csvlog_encode(x265_encoder *encoder, const x265_stats& stats, int argc, char** argv);
                                                                    ^
    /home/ray/ffmpeg_build/include/x265.h:1766:36: error: expected ';', ',' or ')' before '&' token
     void x265_dither_image(x265_picture& pic, int picWidth, int picHeight, int16_t *errorBuf, int bitDepth);
                                        ^
    /home/ray/ffmpeg_build/include/x265.h:1815:50: error: expected ';', ',' or ')' before '&' token
         FILE*         (*csvlog_open)(const x265_param&);
                                                      ^
    /home/ray/ffmpeg_build/include/x265.h:1816:51: error: expected ';', ',' or ')' before '&' token
         void          (*csvlog_frame)(const x265_param&, const x265_picture&);
                                                       ^
    /home/ray/ffmpeg_build/include/x265.h:1817:67: error: expected ';', ',' or ')' before '&' token
         void          (*csvlog_encode)(x265_encoder*, const x265_stats&, int, char**);
                                                                       ^
    /home/ray/ffmpeg_build/include/x265.h:1818:47: error: expected ';', ',' or ')' before '&' token
         void          (*dither_image)(x265_picture&, int, int, int16_t*, int);
                                                   ^
    /home/ray/ffmpeg_build/include/x265.h:1820:1: warning: no semicolon at end of struct or union
     } x265_api;
     ^
    ERROR: x265 not found using pkg-config
    
  7. Werner Robitza

    @RayZX That error has nothing to do with the one reported in this bug. It's just that ffmpeg prints the same final message when one of its library dependencies fails to be included.

  8. Bartek Zdanowski

    Anyway, I had the same problem and I had to add two switches:

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

  9. Log in to comment