fraunhoferhhi / vvenc

VVenC, the Fraunhofer Versatile Video Encoder
https://www.hhi.fraunhofer.de/en/departments/vca/technologies-and-solutions/h266-vvc.html
BSD 3-Clause Clear License
957 stars 172 forks source link

FFmpeg VVC won't detect my libvvenc static only + ld error #188

Closed MartinEesmaa closed 2 years ago

MartinEesmaa commented 2 years ago

Hi, I have a problem linking vvenc into ffmpeg with static build.

Here is my actually commands to build vvenc with disable lto and generator MinGW Makefiles:

cmake -DCMAKE_BUILD_TYPE=Release -DVVENC_ENABLE_LINK_TIME_OPT=OFF -DCMAKE_INSTALL_PREFIX=/mingw64 .. -G "MinGW Makefiles"
cmake --build . --target install -j $nproc

After building and installing vvenc, I checked vvenc installed on mingw64 by using pkg-config before FFmpeg build:

pkg-config --cflags libvvenc
-IC:/msys64/mingw64/include

I used FFmpeg commands to configure and then I got only one error of config.log, gives me ld returned 1 exit status:

./configure --enable-libfdk-aac --enable-libvvenc --enable-libvvdec --enable-static \ 
--disable-shared --enable-pic --enable-libxml2 --enable-zlib --extra-libs='-lpthread -lm -lz' \ 
--extra-ldexeflags=-static --pkg-config-flags=-static --disable-w32threads

config.log error:

gcc -Wl,--nxcompat,--dynamicbase -Wl,--high-entropy-va -Wl,--as-needed -static -Wl,--image-base,0x140000000 -IC:/msys64/mingw64/include -LC:/msys64/mingw64/lib -o /tmp/ffconf.6Mujl6wY/test.exe /tmp/ffconf.6Mujl6wY/test.o -lvvdec -lstdc++ -lm -lpthread -lm -lz
require_pkg_config libvvenc libvvenc >= 1.4.0 vvenc/vvenc.h vvenc_get_version
check_pkg_config libvvenc libvvenc >= 1.4.0 vvenc/vvenc.h vvenc_get_version
test_pkg_config libvvenc libvvenc >= 1.4.0 vvenc/vvenc.h vvenc_get_version
pkg-config --exists --print-errors libvvenc >= 1.4.0
check_func_headers vvenc/vvenc.h vvenc_get_version -IC:/msys64/mingw64/include -LC:/msys64/mingw64/lib -lvvenc -lstdc++ -lm
test_ld cc -IC:/msys64/mingw64/include -LC:/msys64/mingw64/lib -lvvenc -lstdc++ -lm
test_cc -IC:/msys64/mingw64/include -LC:/msys64/mingw64/lib
BEGIN /tmp/ffconf.6Mujl6wY/test.c
    1   #include <vvenc/vvenc.h>
    2   #include <stdint.h>
    3   long check_vvenc_get_version(void) { return (long) vvenc_get_version; }
    4   int main(void) { int ret = 0;
    5    ret |= ((intptr_t)check_vvenc_get_version) & 0xFFFF;
    6   return ret; }
END /tmp/ffconf.6Mujl6wY/test.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1 -D__printf__=__gnu_printf__ -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -std=c11 -fomit-frame-pointer -pthread -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include -IC:/msys64/mingw64/include -LC:/msys64/mingw64/lib -c -o /tmp/ffconf.6Mujl6wY/test.o /tmp/ffconf.6Mujl6wY/test.c
C:/msys64/tmp/ffconf.6Mujl6wY/test.c: In function 'check_vvenc_get_version':
C:/msys64/tmp/ffconf.6Mujl6wY/test.c:3:45: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    3 | long check_vvenc_get_version(void) { return (long) vvenc_get_version; }
      |                                             ^
gcc -Wl,--nxcompat,--dynamicbase -Wl,--high-entropy-va -Wl,--as-needed -static -Wl,--image-base,0x140000000 -IC:/msys64/mingw64/include -LC:/msys64/mingw64/lib -o /tmp/ffconf.6Mujl6wY/test.exe /tmp/ffconf.6Mujl6wY/test.o -lvvenc -lstdc++ -lm -lpthread -lm -lz
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib\libvvenc.a(vvencCfg.cpp.obj):vvencCfg.cpp:(.text+0x5fcb): undefined reference to `apputils::VVEncAppCfg::parse(int, char**, vvenc_config*, std::ostream&)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/lib\libvvenc.a(vvencCfg.cpp.obj):vvencCfg.cpp:(.rdata$.refptr._ZTVN8apputils11VVEncAppCfgE[.refptr._ZTVN8apputils11VVEncAppCfgE]+0x0): undefined reference to `vtable for apputils::VVEncAppCfg'
collect2.exe: error: ld returned 1 exit status
ERROR: libvvenc >= 1.4.0 not found using pkg-config

INFO: I'm using MSYS2 latest version and my gcc version is 12.2.0-1. vvenc version is 1.6.0-rc1 (3651187) cmake version is 3.24.1

Any solutions?

lehmann-c commented 2 years ago

Currently when building static, you have to add the 'apputils' library dependeny to the vvenc pkgconfig file. You can do that by either adapt the file 'pkgconfig/libvvenc.pc.in' before building and install vvenc, or adapt the created 'libvvenc.pc' in the lib/pkgconfig/ path where you have installed vvenc.

You have to change the library dependencies from: Libs: -L${libdir} -lvvenc -lstdc++ -lm
to: Libs: -L${libdir} -lvvenc -lapputils -lstdc++ -lm

Please keep in mind, that this is only needed for static builds.

MartinEesmaa commented 2 years ago

Thank you @lehmann-c, you saved my time! I will close this issue. :)