Build fails using latest tip on mac with multibuild.sh

Issue #351 new
Matthew Oliver created an issue

./multilib.sh -v -- cmake version 3.8.0 -- Detected x86_64 target processor -- Could NOT find NUMA (missing: NUMA_ROOT_DIR NUMA_INCLUDE_DIR NUMA_LIBRARY) -- Found Yasm 1.3.0 to build assembly primitives -- hg found at /usr/local/bin/hg -- x265 version 2.4+75-80c23559084c -- Configuring done -- Generating done -- Build files have been written to: /Matt/Desktop/x265/build/linux/12bit [ 70%] Built target common [ 97%] Built target encoder [ 98%] Linking CXX shared library libx265.dylib Undefined symbols for architecture x86_64: "_x265_version_str", referenced from: x265_12bit::x265_encoder_log(x265_encoder, int, char) in api.cpp.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [libx265.122.dylib] Error 1 make[1]: [CMakeFiles/x265-shared.dir/all] Error 2 make: ** [all] Error 2

Comments (16)

  1. Pradeep Ramachandran Account Deactivated

    Multilib.sh disabled shared deliberately in the cmake command-line as it is designed to only work with static linking. It creates a unified library that can be statically linked with any calling application that in-turn links into statically built 8-bit, 10-bit, or 12-bit x265 libraries.

  2. Matthew Oliver reporter

    I don't understand, as it used to work fine this way... I've been building x265 with -DENABLE_SHARED=ON for the past few months without any trouble.

  3. Pradeep Ramachandran Account Deactivated

    You were enabling SHARED by modifying multilib.sh and it was working ok?

  4. Matthew Oliver reporter

    #!/bin/sh

    mkdir -p 8bit 10bit 12bit

    cd 12bit cmake ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=ON -DENABLE_CLI=OFF -DMAIN12=ON make ${MAKEFLAGS}

    cd ../10bit cmake ../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=ON -DENABLE_CLI=OFF make ${MAKEFLAGS}

    cd ../8bit ln -sf ../10bit/libx265.a libx265_main10.a ln -sf ../12bit/libx265.a libx265_main12.a cmake ../../../source -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON make ${MAKEFLAGS}

  5. Pradeep Ramachandran Account Deactivated

    The original script only generates a libx265.a which can be statically linked against your application. It uses GNU on linux to combine libx265_main.a, ..._main10.a, ..._main12.a into one library, and on MacOS, it uses libtool for this.

    Could you please help me understand why you are generating the libraries with ENABLE_SHARED=ON?

  6. Matthew Oliver reporter

    I'm not linking the libraries, so I can choose which version of x265 I want to use in Handbrake.

  7. Pradeep Ramachandran Account Deactivated

    Ok, so you're not really using the multi-lib build, but are building separate shared libraries and choosing which one to use. Can you check if you're able to build the 8-bit library just directly without using this script (run the cmake for 8-bit alone on the console)?

  8. winnydows

    Same error with latest source if build shared for macOS:

    Undefined symbols for architecture x86_64: "_x265_version_str", referenced from: x265_8bit::x265_encoder_log(x265_encoder, int, char) in api.cpp.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [CMakeFiles/x265-shared.dir/build.make:208: libx265.130.dylib] Error 1 make[1]: [CMakeFiles/Makefile2:139: CMakeFiles/x265-shared.dir/all] Error 2 make: ** [Makefile:130: all] Error 2

    If build static same error will be in linking phase of app that use libx265.a.

    Also new source have bug in x265.h - #include <cstdio> make lib usable in c++ source code only. What wrong with default stdio.h ?

  9. winnydows

    Same error if cross compile for windows:

    libx265_12.a(api.cpp.obj):api.cpp:(.rdata$.refptr.x265_version_str[.refptr.x265_version_str]+0x0): undefined reference to `x265_version_str'

  10. winnydows

    Error happen if build with EXPORT_C_API=OFF only (for enable 8 + 10 + 12), but with ON only one lib can be linked.

  11. winnydows

    Fix:

    diff -rupN original/source/encoder/api.cpp new/source/encoder/api.cpp --- original/source/encoder/api.cpp 2017-06-30 11:16:45.000000000 +0300 +++ new/source/encoder/api.cpp 2017-06-30 11:30:33.000000000 +0300 @@ -295,7 +295,8 @@ void x265_encoder_log(x265_encoder enc, int padx = encoder->m_sps.conformanceWindow.rightOffset; int pady = encoder->m_sps.conformanceWindow.bottomOffset; encoder->fetchStats(&stats, sizeof(stats)); - x265_csvlog_encode(encoder->m_param->csvfpt, x265_version_str, encoder->m_param, padx, pady, stats, encoder->m_param->csvLogLevel, argc, argv); + const x265_api * api = x265_api_get(0); + x265_csvlog_encode(encoder->m_param->csvfpt, api->version_str, *encoder->m_param, padx, pady, stats, encoder->m_param->csvLogLevel, argc, argv); } }

  12. Log in to comment