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

Reply
Contributor
daxfrost
Posts: 20
Registered: ‎07-23-2013
My Device: Z10

Building BlackBerry 3rd party library with Xcode

Hi there,

 

I am trying to do something fairly simple, build a standard C++ library in Xcode and add this library to my BlackBerry application as a 3rd party library.

 

I have seem to generate ".a" and ".so" files but linking in Momentics doesn't give much more than the following:

 

AddLibraryWizardScreenshot.png

 

Any advice would be greatly appreciated. Is this even possible, anything should be?

 

Thank you

Dax

Developer
mzex
Posts: 368
Registered: ‎06-30-2012
My Device: Playbook, Z10LE, DevAlpha C

Re: Building BlackBerry 3rd party library with Xcode

[ Edited ]

Just one question, if this is standard C++ library, why you want to build it in xcode, why not in Momentics ide?

If this library is in objective C, read this: https://developer.blackberry.com/native/documentation/cascades/dev/ios_porting/objccpp.html

 

Contributor
daxfrost
Posts: 20
Registered: ‎07-23-2013
My Device: Z10

Re: Building BlackBerry 3rd party library with Xcode

Hi mzex,

Thank you for the reply.

I have been racking my brain over this for a few weeks. I have a large 3rd party library in Objective C that I need to wrap with a C++ interface. (assuming the PIMPL method is the only option)

I have read the link you sent, and scraped the web for other documentation on this, I've managed to wrap and compile a small test library but I cannot add this through the Momentics IDE as seen above.

Thanks
Dax
Contributor
daxfrost
Posts: 20
Registered: ‎07-23-2013
My Device: Z10

Re: Building BlackBerry 3rd party library with Xcode

So I have managed to compile with Xcode.

 

I then use libtool to extract my .so files for 2 valid architectures: armv7 and armv7s.

 

On importing these to Momentics, I see...

 

 Library is not compiled for the correct architecture: *path to my file*

 

If anyone has guidance on why these are not correct, it would be much appreciated.

 

I'm assuming others have compiled with Xcode and imported their libraries to Momentics BlackBerry projects.

 

Thank you

Dax

Contributor
daxfrost
Posts: 20
Registered: ‎07-23-2013
My Device: Z10

Re: Building BlackBerry 3rd party library with Xcode

The linking / building process is not explained in this documentation: http://developer.blackberry.com/native/documentation/cascades/dev/ios_porting/objccpp.html

 

I have left a comment on this in hopes of a BlackBerry developer that has an example or answer to this would clarify their documentation.

 

I have opened another thread to further explain my issue: http://stackoverflow.com/questions/19406949/can-i-use-xcode-compiled-armv7-armv7s-so-library-in-blac...

BlackBerry Development Advisor
EunKyung
Posts: 43
Registered: ‎09-27-2012
My Device: Passport

Re: Building BlackBerry 3rd party library with Xcode

Hi,
I suggest to try building the lib with gcc option in Xcode. This may match the binary file and resolve your error msg. If that doesn't work, try building your source code in Momentics to create the lib. I know this is not the ideal solution for you but maybe worth to try to see if works. Also you can set the build options to use gcc in Momentics to match the compiler options through out.
----------------------------------------------------
Hope this was helpful. Happy Coding!
EK @echotown
Contributor
daxfrost
Posts: 20
Registered: ‎07-23-2013
My Device: Z10

Re: Building BlackBerry 3rd party library with Xcode

Hi Eun,

I have compiled 2 tests outside of Xcode with GCC and QCC.


The files from GCC compiler (armv7 as an ".so" lib) still produce "incorrect architecture" in Momentics...

After that, I tried extracting and repackaging the ".o" object files with QCC:

 

daxfrost$ qcc -Vgcc_ntoarmv7le -shared -o libQCCShared_armv7.so ./obj/*.o

./obj/Test.o: file not recognized: File format not recognized

 

Looking at the format of the GCC produced .so library and one of its .o object file:


daxfrost$ file libShared_armv7.so
libShared_armv7.so: current ar archive random library
daxfrost$ file Test.o
Test.o: Mach-O object arm


Whereas the object files from the compatible library built with the QCC compiler are in ELF format.


daxfrost$ file libShared.so
libShared.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped
daxfrost$ file Test.o
Test.o: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

 

I am able to link this fine in Momentics, which leads me to believe that the "invalid architecture" refers to this difference in format? ...And the reason I am looking for an example or more info in the documentation.

 

Thank you for your assitance.

-Dax

BlackBerry Development Advisor
EunKyung
Posts: 43
Registered: ‎09-27-2012
My Device: Passport

Re: Building BlackBerry 3rd party library with Xcode

Hi Dax,

 

Thanks for sharing what you found. It makes sense that you got the error message about the different architeture since Mach-O is not supported on Momentics/BB platform.  

It should definitetly documented that the defferences and issues during the compile and build process. I'll get in touch with the BlacBerry doc team to address the possible issues like you are going through.

 

Thanks,

E. 

 

 

----------------------------------------------------
Hope this was helpful. Happy Coding!
EK @echotown
Contributor
daxfrost
Posts: 20
Registered: ‎07-23-2013
My Device: Z10

Re: Building BlackBerry 3rd party library with Xcode

Thanks Eun,

 

Could you please let me know what the outcome is, as the documentation lead me to believe one can wrap Objective C code and use it on the BlackBerry platform.

 

I'd just like to know if this is not true.

 

-Dax