Steps to Include Prebuilt Libraries - 2020.2 English

PetaLinux Tools Documentation Reference Guide (UG1144)

Document ID
UG1144
Release Date
2020-11-24
Version
2020.2 English

If your prebuilt library name is mylib.so, including this into PetaLinux root file system is explained in following steps.

  1. Ensure that the pre-compiled code has been compiled for your PetaLinux target architecture, for example, MicroBlaze™ processors, Arm® cores, etc.
  2. Create an application with the following command.
    $ petalinux-create -t apps --template install --name mylib --enable
    
    Note: --enable should be executed after the petalinux-config command.
  3. Change to the newly created application directory.
    $ cd <plnx-proj-root>/project-spec/meta-user/recipes-apps/mylib/files/
    
  4. Remove existing mylib file, and copy the prebuilt mylib.so into mylib/files directory.
    $ rm mylib
    $ cp <path-to-prebuilt-mylib.so> ./
  5. Create an application and include a prebuilt library into the root file system with a single command instead of following steps 2, 3, and 4. The following command creates mylib app and copies mylib.so from <path-to-dir> to mylib/files directory.
    $ petalinux-create -t apps --template install --name mylib --srcuri <path-to-dir>/mylib.so --enable
    Note: This is applicable for applications and modules.
  6. Create an application with multiple source files.
    $ petalinux-create -t apps --template install --name mylibs --srcuri "<path-to-dir>/mylib1.so <path-to-dir>/mylib2.so"
    Note: This is applicable for applications and modules.
  7. Create an app with remote sources. The following examples will create applications with specified git/http/https pointing to the srcuri.
    $ petalinux-create -t apps -n myapp --enable --srcuri http://example.tar.gz
    $ petalinux-create -t apps -n myapp --enable --srcuri git://example.git\;protocol=https
    $ petalinux-create -t apps -n myapp --enable --srcuri https://example.tar.gz
    Note: This is applicable for applications and modules.
  8. Edit <plnx-proj-root>/project-spec/meta-user/recipes-apps/mylib/mylib.bb.

    The file should look like the following.

    # This file is the libs recipe.
    #
    
    SUMMARY = "Simple libs application"
    SECTION = "PETALINUX/apps"
    LICENSE = "MIT"
    LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
    
    SRC_URI = "file://mylib.so \
     "
    
    S = "${WORKDIR}"
    
    TARGET_CC_ARCH += "${LDFLAGS}"
    
    do_install() {
          install -d ${D}${libdir}
          install -m 0655 ${S}/mylib.so ${D}${libdir}
    }
    
    FILES_${PN} += "${libdir}"
    FILES_SOLIBSDEV = ""
  9. Run petalinux-build -c rootfs.
Important: You need to ensure that the binary data being installed into the target file system by an install template application is compatible with the underlying hardware implementation of your system.