5 Replies Latest reply on Apr 14, 2016 4:28 PM by Intel Corporation

    Making a Yocto Recipe that copies dynamic library (.so) to /usr/lib

    Angelo-Ribeiro-Microsoft

      Hi,

       

      I'm creating a recipe to add on my image. My product have 1 executable and 4 libraries, which I load dynamically.

       

      Here is how my recipe looks like:

      FILESEXTRAPATHS_prepend := "${THISDIR}/files/:"

      SRC_URI += "file://<myexecutionfile>"
      SRC_URI += "file://<myexecutionfile>.service"
      SRC_URI += "file://<dynamiclibrary1>.so"
      SRC_URI += "file://<dynamiclibrary2>.so"
      SRC_URI += "file://<dynamiclibrary3>.so"
      SRC_URI += "file://<dynamiclibrary4>.so"

      SYSTEMD_SERVICE_${PN} = "<myexecutionfile>.service"

      RDEPENDS_${PN} = "systemd"
      DEPENDS = "systemd"

      inherit systemd

      S = "${WORKDIR}"

      do_compile() { 

          

      }

      do_install() {
              # install service file
              install -d ${D}${systemd_unitdir}/system
              install -c -m 0644 ${WORKDIR}/<myexecutionfile>.service ${D}${systemd_unitdir}/system

              # install my binary
              install -d ${D}${bindir}
              install -c -m 0755 ${B}/<myexecutionfile> ${D}${bindir}

               # install my libraries
               install -d ${D}${libdir}
               install -c -m 0755 ${B}/<dynamiclibrary1>.so ${D}${libdir}
               install -c -m 0755 ${B}/<dynamiclibrary2>.so ${D}${libdir}
               install -c -m 0755 ${B}/<dynamiclibrary3>.so ${D}${libdir}
               install -c -m 0755 ${B}/<dynamiclibrary4>.so ${D}${libdir}
      }

      FILES_${PN} = "${base_libdir}/systemd/system/<myexecutionfile>..service"
      FILES_${PN} += "${bindir}/<myexecutionfile>."
      FILES_${PN} += "${libdir}/<dynamiclibrary1>.so"
      FILES_${PN} += "${libdir}/<dynamiclibrary2>.so"
      FILES_${PN} += "${libdir}/<dynamiclibrary3>.so"
      FILES_${PN} += "${libdir}/<dynamiclibrary4>.so"

       

       

      With that I have my executable copied to /usr/bin, but my dynamic libraries were not copied to /usr/lib... If I change from ${libdir}  to ${binddir}  I got the .so copied to /usr/bin, but this isn't what I want.

       

      Do you have any idea why this is not working or what would be the correct way to have my dynamic libraries installed into /etc/lib?

       

       

      Thanks a lot in advance,

       

      Angelo Ribeiro.

        • 1. Re: Making a Yocto Recipe that copies dynamic library (.so) to /usr/lib
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hi Angelo,

          Have you tried using /usr/lib instead of {bindir} or {libdir}?
          Also, you mentioned that you would like to include them on /etc/lib; I’ve seen these libraries on /usr/lib but not on /etc/lib. Are you creating this folder on your filesystem?

          Regards,
          Charlie
           

          • 2. Re: Making a Yocto Recipe that copies dynamic library (.so) to /usr/lib
            Angelo-Ribeiro-Microsoft

            Thanks Charlie,

             

            /etc/lib was a typo, i want to put on /usr/lib.

             

            I tried a bunch of variations without success.

             

            DId you see any sample that generated a .so file and deployed into /usr/lib?

             

            Also, do you know a good way of debugging these recipes? (like with echo or printf?)

             

            Thanks

             

            Angelo Ribeiro

            • 3. Re: Making a Yocto Recipe that copies dynamic library (.so) to /usr/lib
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Hi Angelo,

              Have you checked if the .so are located on /lib? When you bitbake the image, do you get errors? Run a find instruction to see if the .so are being generated and where have been located when you build your image.
              Did you also try without the FILES_${PN} lines? There could be a conflict with these instructions and install -d ${D}${libdir}.
              I will do some tests and investigate regarding this and I will let you know, please let me know about my questions above.

              What do you want to debug? How are the recipes being built or all the build process?
              You can find some information here: http://www.yoctoproject.org/docs/1.7/ref-manual/ref-manual.html#usingpoky-debugging You can also use FILES_${PN}-dbg.  Let me know if this approach helps on how you want to debug this.

              Regards,
              Charlie

              • 4. Re: Making a Yocto Recipe that copies dynamic library (.so) to /usr/lib
                Angelo-Ribeiro-Microsoft

                Hi Chalie,

                 

                Yep, I have checked on /lib and everyplace and the .so was not there. It seems like we have a conflict when we put FILES_${PN}  and do_install...

                 

                So, I fixed by adding the following like on my makefiles (not on my BB).

                 

                So, here is how I fixed the problem:

                 

                1. Starting compiling my code, instead of copying binaries;
                2. Added the following line on my makefiles: install(TARGETS <myExecutableName> DESTINATION bin) for executables and install(TARGETS <MyLibraryName> LIBRARY DESTINATION lib) for libraries.
                3. Changed my recipe (removed the do_install...

                So, my new recipe is like this:

                DESCRIPTION = ""

                LICENSE = ""

                SRC_URI = "file:///home/<MyUser>/<Folder where my source files are with makefiles>"

                 

                 

                LIC_FILES_CHKSUM = "file:///<path to my license file.>;md5=4283671594edec4c13aeb073c219237a"

                 

                 

                PROVIDES = "<NAme of my recipe to be used in image-edison.bb>"

                 

                 

                DEPENDS = "glib-2.0 curl"

                 

                 

                EXTRA_OECMAKE = "<Some CMAke Parameters here.>"

                 

                 

                S = "${WORKDIR}/home/<Folder where my source files are with makefiles>"

                 

                 

                SYSTEMD_SERVICE_${PN} = "<name of my executable>.service"

                 

                 

                FILES_${PN} = "${systemd_unitdir}/system/*"

                FILES_${PN} += "${bindir}/*"

                FILES_${PN} += "${libdir}/*.so"

                 

                 

                FILES_SOLIBSDEV = ""

                 

                 

                inherit pkgconfig cmake systemd

                 

                 

                do_install_append() {

                  # install service file

                  install -d ${D}${systemd_unitdir}/system

                  install -c -m 0644 ${WORKDIR}/home/azure-iot-field-gateway-sdk/samples/simple_device_cloud_upload/src/simple_device_cloud_upload.service ${D}${systemd_unitdir}/system

                   

                <had to add an addition install to copy a JSON File to a folder here.>

                 

                }

                 

                 

                That's it! Problem solved!

                 

                Thanks!

                 

                Angelo Ribeiro.

                • 5. Re: Making a Yocto Recipe that copies dynamic library (.so) to /usr/lib
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hi Angelo,

                  I’m very glad to know that you were able to solve this. 

                  Kind regards,
                  Charlie