Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development Knowledge Base

How to create a shared or static library to be used in other Cascades C++ projects

by Retired on ‎09-12-2012 02:04 PM - edited on ‎04-01-2014 10:15 AM by Retired (8,786 Views)

This article will show you how to create shared and or static libraries to be used by other Cascades™ C++ projects.

 

Shared libraries are usually preferred, however, in some cases, static libraries may be required; (e.g. statically linked code tends to be executed more efficiently than the dynamically linked code, which may be very important for high performance.)

 

The screenshots in this article were taken from BlackBerry® 10 Native SDK(Momentics IDE) on the Mac platform, which are also applicable to other platforms with the exception of paths.

 

  1.  From BlackBerry 10 Native SDK(Momentics IDE), select File > New > BlackBerry Project. Create a Static or Shared library project type.

 

Untitled.jpg

 

 

 2.  Input project name and select language, then, press "Next" button

 

SharedLib2.jpg

 

 

3. Choose API Level, then, press "Finish" button.

 

SharedLib3.jpg

 

 

4. Once the project template is created, add the source files to the project.

 

5. Build the project.

 

For more information and code samples, check out a shared library template and sample app on GitHub. 

 

https://github.com/blackberry/Cascades-Community-Samples/tree/master/Cascades-Library-Template

 

 

Related Articles

How to use a third party shared or static library in a Cascades C++ project

 

Comments
by Developer
on ‎02-28-2014 01:22 PM

Time to update this article… unfortunately more than old Smiley Sad

by New Developer
on ‎08-17-2014 02:34 PM

Trying to create and use a cascades/c++ library.  I have a number of C++/cascades classes in my application that I want to include in a seaparate library for re-use in other apps. The code in these classes runs fine when included directly in the application. When I create a Cascades library and move the source and header files to it, then the library appears to build correctly, but when I try to include it in thr app I get the following errors.  I have followed all the instructions in the readme.txt file generated by the Cascades library wizard, and I have tried to follow some of the forum post suggestions, but nothing seems to fix the problem.  Can somebody please tell me what the problem is.

 

15:22:54 **** Incremental Build of configuration Device-Debug for project Barcode4business ****
make -j2 Device-Debug
make -C .//translations -f Makefile update
make[1]: Entering directory `C:/momentics-workspace/Barcode4business/translations'
C:/bbndk/host_10_2_0_15/win32/x86/usr/bin/lupdate BarcodeSniffer.pro
lupdate warning: no TS files specified. Only diagnostics will be produced for 'BarcodeSniffer.pro'.
make[1]: Leaving directory `C:/momentics-workspace/Barcode4business/translations'
make -C .//translations -f Makefile release
make[1]: Entering directory `C:/momentics-workspace/Barcode4business/translations'
C:/bbndk/host_10_2_0_15/win32/x86/usr/bin/lrelease BarcodeSniffer.pro
lrelease warning: Met no 'TRANSLATIONS' entry in project file 'BarcodeSniffer.pro'
make[1]: Leaving directory `C:/momentics-workspace/Barcode4business/translations'
make -C ./arm -f Makefile debug
make[1]: Entering directory `C:/momentics-workspace/Barcode4business/arm'
make -f Makefile.Debug
make[2]: Entering directory `C:/momentics-workspace/Barcode4business/arm'
qcc -Vgcc_ntoarmv7le -lang-c++ -Wl,-rpath-link,C:/bbndk/target_10_2_0_1155/qnx6/armle-v7/lib -Wl,-rpath-link,C:/bbndk/target_10_2_0_1155/qnx6/armle-v7/usr/lib -Wl,-rpath-link,C:/bbndk/target_10_2_0_1155/qnx6/armle-v7/usr/lib/qt4/lib -o o.le-v7-g/Barcode4business o.le-v7-g/.obj/ActiveFrameQML.o o.le-v7-g/.obj/Timer.o o.le-v7-g/.obj/applicationui.o o.le-v7-g/.obj/main.o o.le-v7-g/.obj/moc_ActiveFrameQML.o o.le-v7-g/.obj/moc_Timer.o o.le-v7-g/.obj/moc_applicationui.o    -LC:/bbndk/target_10_2_0_1155/qnx6/armle-v7/lib -LC:/bbndk/target_10_2_0_1155/qnx6/armle-v7/usr/lib -LC:/bbndk/target_10_2_0_1155/qnx6/armle-v7/usr/lib/qt4/lib -LC:/bbndk/target_10_2_0_1155/qnx6//usr/lib/qt4/lib -lbb -lbbcascadesmultimedia -lbbdevice -lbbmultimedia -lbbsystem -lcamapi -lscreen -lzxing -lmmrndclient -lasound -L../assets -lBarcodeScanner -L../../DpUtilities/arm/so.le-v7-g -LC:/momentics-workspace/Barcode4business/../DpUtilities/arm/so.le-v7-g -LC:/momentics-workspace/DpUtilities/arm/a.le-v7-g -lDpUtilities -LC:/bbndk/target_10_2_0_1155/qnx6/usr/share/qt4/lib -lQtSensors -lbbcascades -lQtDeclarative -lQtScript -lQtSvg -lQtSql -lsqlite3 -lz -lQtXmlPatterns -lQtGui -lQtNetwork -lsocket -lQtCore -lm -lbps
o.le-v7-g/.obj/applicationui.o: In function `~CameraScannerControl':
C:\momentics-workspace\Barcode4business\arm/../../DpUtilities/include/CameraScanner.hpp:50: undefined reference to `Scanner::~Scanner()'
C:\momentics-workspace\Barcode4business\arm/../../DpUtilities/include/CameraScanner.hpp:50: undefined reference to `vtable for CameraScannerControl'
C:\momentics-workspace\Barcode4business\arm/../../DpUtilities/include/CameraScanner.hpp:50: undefined reference to `vtable for CameraScannerControl'
o.le-v7-g/.obj/applicationui.o: In function `int qmlRegisterType<CameraScannerControl>(char const*, int, int, char const*)':
C:\momentics-workspace\Barcode4business\arm/../../../bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtDeclarative/qdeclarative.h:162: undefined reference to `CameraScannerControl::staticMetaObject'
C:\momentics-workspace\Barcode4business\arm/../../../bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtDeclarative/qdeclarative.h:162: undefined reference to `CameraScannerControl::staticMetaObject'
C:\momentics-workspace\Barcode4business\arm/../../../bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtDeclarative/qdeclarative.h:188: undefined reference to `CameraScannerControl::staticMetaObject'
C:\momentics-workspace\Barcode4business\arm/../../../bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtDeclarative/qdeclarative.h:188: undefined reference to `CameraScannerControl::staticMetaObject'
o.le-v7-g/.obj/applicationui.o: In function `QDeclarativeElement':
C:\momentics-workspace\Barcode4business\arm/../../../bbndk/target_10_2_0_1155/qnx6/usr/include/qt4/QtDeclarative/qdeclarativeprivate.h:87: undefined reference to `CameraScannerControl::CameraScannerControl(bb::cascades::Container*)'
o.le-v7-g/.obj/applicationui.oSmiley Sad.rodata._ZTVN19QDeclarativePrivate19QDeclarativeElementI20CameraScannerControlEE[_ZTVN19QDeclarativePrivate19QDeclarativeElementI20CameraScannerControlEE]+0x8): undefined reference to `CameraScannerControl::metaObject() const'
o.le-v7-g/.obj/applicationui.oSmiley Sad.rodata._ZTVN19QDeclarativePrivate19QDeclarativeElementI20CameraScannerControlEE[_ZTVN19QDeclarativePrivate19QDeclarativeElementI20CameraScannerControlEE]+0xc): undefined reference to `CameraScannerControl::qt_metacast(char const*)'
o.le-v7-g/.obj/applicationui.oSmiley Sad.rodata._ZTVN19QDeclarativePrivate19QDeclarativeElementI20CameraScannerControlEE[_ZTVN19QDeclarativePrivate19QDeclarativeElementI20CameraScannerControlEE]+0x10): undefined reference to `CameraScannerControl::qt_metacall(QMetaObject::Call, int, void**)'
o.le-v7-g/.obj/applicationui.oSmiley Sad.rodata._ZTIN19QDeclarativePrivate19QDeclarativeElementI20CameraScannerControlEE[_ZTIN19QDeclarativePrivate19QDeclarativeElementI20CameraScannerControlEE]+0x8): undefined reference to `typeinfo for CameraScannerControl'
cc: C:/bbndk/host_10_2_0_15/win32/x86/usr/bin/ntoarm-ld caught signal 1
make[2]: *** [o.le-v7-g/Barcode4business] Error 1
make[2]: Leaving directory `C:/momentics-workspace/Barcode4business/arm'
make[1]: *** [debug] Error 2
make[1]: Leaving directory `C:/momentics-workspace/Barcode4business/arm'
make: *** [Device-Debug] Error 2

15:22:57 Build Finished (took 2s.950ms)

Users Online
Currently online: 32 members 3,812 guests
Please welcome our newest community members: