libyang icon indicating copy to clipboard operation
libyang copied to clipboard

Unresolved external: lyd_free_meta_single (but no other) with shared lib

Open capiman opened this issue 1 year ago • 1 comments

I am trying to compile rousette (in an yocto environment, cross-compiling). Meanwhile a lot progress, but 1 link error remains:

lyd_free_meta_single is reported as unresolved

| /builds/xxx/imagebuilder2-imx8mp/build/tmp-ampliphy-xxx/work/cortexa53-crypto-phytec-linux/rousette/1.0.0/recipe-sysroot-native/usr/bin/aarch64-phytec-linux/../../libexec/aarch64-phytec-linux/gcc/aarch64-phytec-linux/13.3.0/ld: /builds/xxx/imagebuilder2-imx8mp/build/tmp-ampliphy-xxx/work/cortexa53-crypto-phytec-linux/rousette/1.0.0/recipe-sysroot/usr/lib/libsysrepo-cpp.so: undefined reference to symbol 'lyd_free_meta_single'
| /builds/xxx/imagebuilder2-imx8mp/build/tmp-ampliphy-xxx/work/cortexa53-crypto-phytec-linux/rousette/1.0.0/recipe-sysroot-native/usr/bin/aarch64-phytec-linux/../../libexec/aarch64-phytec-linux/gcc/aarch64-phytec-linux/13.3.0/ld: /builds/xxx/imagebuilder2-imx8mp/build/tmp-ampliphy-xxx/work/cortexa53-crypto-phytec-linux/rousette/1.0.0/recipe-sysroot/usr/lib/libyang.so.3: error adding symbols: DSO missing from command line
| collect2: error: ld returned 1 exit status

Why only this and none of the other symbols?

Any idea what it could be?

I tried already latest master, as well as latest from develop, but error remains.

capiman avatar Aug 05 '24 06:08 capiman

This isn't a bug in libyang. (And just FYI, we're regularly doing cross-builds of libyang, libyang-cpp and rousette for 32bit ARM in our internal CI, and I've never seen this.)

The error means that the linker cannot find that symbol in libsysrepo-cpp.so, and it's hinting to you that it's available in libyang.so.3. That sound correct; the symbol is indeed provided by libyang (the C library), then it's wrapped by a class method (libyang::MetaCollection::erase) in libyang-cpp (the C++ wrapper), and it looks like it's only used in rousette's src/sr/AllEvents.cpp (at two places in that file). There's no place in sysrepo-cpp where that symbol is used AFAICT. Now, the CMake rules for rousette produce a static library rousette-sysrepo which "publicly uses" (that's my wording of a CMake concept) both sysrepo-cpp and libyang-cpp, so I do not see any error in there.

  • Can you please explicitly confirm that there's no build state whatsoever from some previous build attempts present at the system?
    • No stray libraries anywhere in your path, etc?
    • No reused build directories?
  • Do you see that symbol as provided in your:
    • libyang.so.X
    • libyang-cpp.so
    • sysrepo.so.X
    • in sysrepo-cpp.so?
    • Is it provided or used?
  • What are your exact compiler and CMake versions?
  • What versions (as in specific git commit hashes) of libyang, libyang-cpp, sysrepo, sysrepo-cpp and rousette are you building?

jktjkt avatar Aug 05 '24 09:08 jktjkt