If your prebuilt library name is mylib.so, including this into PetaLinux root file system is explained in following steps.
- Ensure that the pre-compiled code has been compiled for your PetaLinux target architecture, for example, MicroBlaze™ processors, Arm® cores, etc.
- Create an application with the following
command.
$ petalinux-create -t apps --template install --name mylib --enable
Note:--enable
should be executed after thepetalinux-config
command. - Change to the newly created application directory.
$ cd <plnx-proj-root>/project-spec/meta-user/recipes-apps/mylib/files/
- Remove existing mylib file,
and copy the prebuilt mylib.so into
mylib/files directory.
$ rm mylib $ cp <path-to-prebuilt-mylib.so> ./
- 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. - 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. - 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. - 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 = ""
- 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.