Q:

What is the correct way of adding standard library to yocto image

I have custom image created based on the yocto project to run on a Arm cortex A9 processor which is on a Zynq. I compile my application with a cross-compiler on my Linux machine, and trying to run it on Arm. But it gives an error asking that it cannot find the libstdc++6 library. This library is really not included on my image. When I manually copy the libstdc++.so.6 to /lib folder on target, it runs successfully. Hence I want to build my image to include that library itself. I tried creating a recipe like seen below
DESCRIPTION = "Copy necessary lib files to rootfs/lib directory"
LICENSE = "CLOSED"
PACKAGE_ARCH = "all"
SRC_URI += " \
    file://libstdc++.so.6 \
    file://libstdc++.so.6.0.22 \
"

do_install () {
    install -d ${D}${base_libdir}/
    install -m 755 ${WORKDIR}/libstdc++.so.6 ${D}${base_libdir}/
    install -m 755 ${WORKDIR}/libstdc++.so.6.0.22 ${D}${base_libdir}/
}

FILES_${PN} += " \
    ${base_libdir}/libstdc++.so.6 \
    ${base_libdir}/libstdc++.so.6.22 \
"

but it gives the error that those libraries already exists in a shared area. But I cannot figure out how to copy from that shared are to /lib directory in image. Here is the error:

ERROR: my-recipe-1.0-r0 do_packagedata: The recipe my-recipe is trying
  to install files into a shared area when those files already exist.
  Those files and their manifest location are:
  /home/myUser/REPOS/my-platform/build/tmp-glibc/sysroots/my-board-xc7z030/pkgdata/runtime-reverse/libstdc++6
  Matched in b'manifest-my-board-xc7z030-gcc-runtime.packagedata' 
  /home/myUser/REPOS/my-platform/build/tmp-glibc/sysroots/my-board-xc7z030/pkgdata/runtime-reverse/libstdc++-dev  Matched in b'manifest-my-board-xc7z030-gcc-runtime.packagedata' Please
  verify which recipe should provide the above files.

So what is the correct way of putting the standard library into the image?
Thanks!

A:

You don't need to explicitly add libraries to your image, if you've got an application that links againts it (at least as you're linking normally to them).
Instead, write a recipe for your C++ application. In the case of libstdc++.so.6, this runtime dependency will be automatically detected for you.
Had it been another library, you'd need add it's recipe to you build time dependencies, DEPENDS; the runtime part would still be handled automatically.
Update:
If you want to add libstdc++.so.6 to your image, without adding any C++ application; just add
 IMAGE_INSTALL_append = " libstdc++6"

