This article demonstrates how to use third party shared or static libraries in a Cascades™ C++ project. There are two parts for this task:
1) Compiling and linking the Cascades C++ project code with the third party library.
2) Deploying the third party shared library to the target if the libraries are dynamically linked.
This article assumes that you have a Cascades C++ project created using the BlackBerry® Native SDK that will need to use third party libraries
The examples shown in this article pertain to Mac/Linux®; Windows® users will need adjust the file path for the library files.
Part A: Configure the Cascades C++ project to compile and link with the third party libraries
Edit the .pro file to update the INCLUDEPATH to add the path of the header files of the pre-built header libraries.
INCLUDEPATH += <Path to the lib header files>
Note: if your .pro does not define INCLUDEPATH, you just add this line to .pro file.
2. Edit the .pro file to update the LIBS to add the pre-built libraries.
LIBS += -L<path to the libs> -l<lib name>
for example: if your object file is “/usr/someuser/workdir/libdummy.so”,
LIBS += -L/usr/someuser/workdir/ -ldummy
If you want to statically link with this lib (assuming you have the static version of lib under the same location), you will need to add the "-Bstatic" compiler flag for this lib and append "-Bdynamic \" at the end so that other libs will still be linked dynamically.
LIBS += -Bstatic -L<path to the libs> -l<lib name> -Bdynamic \
for example: if your object file is “/usr/someuser/workdir/libdummy.a”,
An Alternative method of bundling third party libs:
You can manually add the shared lib files to the project “assets”, then manually edit the value of “LD_LIBRARY_PATH" in the bar-descriptor.xml file to contain the path pointing to the bundled shared lib files.
For example, if you copy shared lib files to the “assets/myLib”, then, you will have