x265 multi bit depth does not compile dlopen
Issue #520
new
Using the next script I get a compilation error in the last step
SCRIPT
local ld_flags=$LDFLAGS
local extra_cmake_options="-DENABLE_SHARED=0 -DENABLE_PIC=1"
mkdir -p 8bit 10bit 12bit
cd 12bit
do_cmake "-DCMAKE_INSTALL_PREFIX=$install_prefix $extra_cmake_options -DHIGH_BIT_DEPTH=1 -DENABLE_HDR10_PLUS=1 -DMAIN12=1 -DEXPORT_C_API=0 -DENABLE_CLI=0" ../source
do_make
cp libx265.a ../8bit/libx265_main12.a
cd ../10bit
do_cmake "-DCMAKE_INSTALL_PREFIX=$install_prefix $extra_cmake_options -DHIGH_BIT_DEPTH=1 -DENABLE_HDR10_PLUS=1 -DMAIN10=1 -DEXPORT_C_API=0 -DENABLE_CLI=0" ../source
do_make
cp libx265.a ../8bit/libx265_main10.a
cd ../8bit
if [[ $compiler_flavors != android* ]]; then
extra_cmake_options+=" -DENABLE_CLI=1"
else
extra_cmake_options+=" -DENABLE_CLI=0"
fi
do_cmake "-DCMAKE_INSTALL_PREFIX=$install_prefix $extra_cmake_options -DHIGH_BIT_DEPTH=0 -DENABLE_HDR10_PLUS=0 -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=1 -DLINKED_12BIT=1 -DEXTRA_LIB=x265_main10.a;x265_main12.a -DEXPORT_C_API=1" ../source
do_make
mv libx265.a libx265_main.a
if [[ $OSTYPE == linux* ]]; then
ar -M <<EOF
CREATE libx265.a
ADDLIB libx265_main.a
ADDLIB libx265_main10.a
ADDLIB libx265_main12.a
SAVE
END
EOF
else
libtool -static -o libx265.a libx265_main.a libx265_main10.a libx265_main12.a 2>/dev/null
fi
do_make_install
cd ..
export LDFLAGS=$ld_flags
ERROR
./libx265_main10.a(api.cpp.o): In function `x265_10bit::x265_api_get_179(int)':
api.cpp:(.text+0x1bd4): undefined reference to `dlopen'
api.cpp:(.text+0x1bec): undefined reference to `dlsym'
api.cpp:(.text+0x1c7d): undefined reference to `dlopen'
./libx265_main10.a(api.cpp.o): In function `x265_10bit::x265_api_query(int, int, int*)':
api.cpp:(.text+0x1d37): undefined reference to `dlopen'
api.cpp:(.text+0x1d4f): undefined reference to `dlsym'
api.cpp:(.text+0x1e05): undefined reference to `dlopen'
./libx265_main12.a(api.cpp.o): In function `x265_12bit::x265_api_get_179(int)':
api.cpp:(.text+0x1bd4): undefined reference to `dlopen'
api.cpp:(.text+0x1bec): undefined reference to `dlsym'
api.cpp:(.text+0x1c7d): undefined reference to `dlopen'
./libx265_main12.a(api.cpp.o): In function `x265_12bit::x265_api_query(int, int, int*)':
api.cpp:(.text+0x1d37): undefined reference to `dlopen'
api.cpp:(.text+0x1d4f): undefined reference to `dlsym'
api.cpp:(.text+0x1e05): undefined reference to `dlopen'
collect2: error: ld returned 1 exit status
make[2]: *** [x265] Error 1
make[1]: *** [CMakeFiles/cli.dir/all] Error 2
make: *** [all] Error 2
I ran into this as well when compiling 3.4 with GCC 9.3.0 on Ubuntu 20.04. I’ve also done cross-compiles with mingw-w64 on GCC 9.3.0 and 10.1.0 but those didn’t have any issue.
I found two workarounds to get the build to succeed.
First by just setting DENABLE_CLI=0 to only build the library; the resulting library has worked so far without any issue in ffmpeg for me.
I was also able to get the CLI to build by setting DENABLE_SHARED=0 and DEXTRA_LIB=libx265_main10.a;libx265_main12.a;-ldl to force using libdl. If I only changed one of those it still failed for me. Again the library from this has worked fine for me so far in ffmpeg. I did some quick testing of the CLI and didn’t notice any issues either, but since I mostly use ffmpeg I haven’t tested it extensively.