After the library has been added to the project of a Qt app, the packaging process for the app remains mostly the same, except for two extra steps.
QMAKE_LFLAGS += "-Wl,-rpath,app/native/lib"
This instruction embeds the path of the library file (libQtLibrary.so) into the QtApp binary. When the launcher service runs QtApp in its sandbox environment, the service uses a root path of app/native. All files within the Blackberry ARchive (BAR) package are relative to this location. For instance, from the perspective of QtApp, its icon file is found at app/native/icon.png.
To package libQtLibrary.so into the lib subdirectory in the BAR file, we set rpath to the root path appended with this subdirectory (i.e., app/native/lib).
QtApp.bar %{sourceDir}\bar-descriptor.xml QtApp -C %{sourceDir} %{sourceDir}\icon.png -e ProjectBuildDir\libQtLibrary.so.1.0 lib/libQtLibrary.so.1
The newly added –e option is followed by two paths. The first is the library file's build location on the host system (in this case, replace ProjectBuildDir with the path containing the output library file) and the second is the relative location of the library file within the BAR package. Note that the file is purposely renamed from libQtLibrary.so.1.0 to libQtLibrary.so.1.
If you're using Qt Creator to package the app, you must access the Build & Run tab and edit the build step for the packaging command to add these arguments, as explained in "Packaging the app into a BAR file from Qt Creator". In the above example, ProjectBuildDir is the build directory specified in the General section of the Build Settings page.
You can also package the app from the command line, by passing these arguments to blackberry-nativepackager in a QNX Neutrino terminal, as described in "Packaging the BAR file from the command line".