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
PJDavis1970
Posts: 44
Registered: ‎01-22-2013
My Device: Z10, Q10, Z10 Alpha
My Carrier: None
Accepted Solution

Static Library linking

Hi,

 

I have searched the forums and although I have found many posts related to similar issues I have not found one to actually solve my issue.

 

Basically I am trying to link my static library into my BB10 project.  I am building 2 versions of my library.  A simulator and a Device version.

 

The library will be shipped with the actual apps project so I am adding the libraries to the root of the projects directory.

 

eg :

 

Project\libs\Simulator\library. a

Project\libs\Device\library.a

 

How to I link against this library in my main project depending if im building a simulator or device build?

 

Thanks

 

 

Please use plain text.
Contributor
PJDavis1970
Posts: 44
Registered: ‎01-22-2013
My Device: Z10, Q10, Z10 Alpha
My Carrier: None

Re: Static Library linking

[ Edited ]

Can no one help me on this?

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Static Library linking

You have two separate Project Settings - for device and for simulator. In onw of them specify library path Project\libs\Device and in other one Project\libs\Simulator

Please use plain text.
Contributor
PJDavis1970
Posts: 44
Registered: ‎01-22-2013
My Device: Z10, Q10, Z10 Alpha
My Carrier: None

Re: Static Library linking

[ Edited ]

Hi, Thanks for response.

 

I have tried settings these and it still failed to find the library.

 

After setting these it writes the following lines to the .pri file but the linker still cannot find the libs ( as you can see these entries are incorrectly formatted )

 

$$quote($$BASEDIR/..//BBOmnisWrapper/libs/Device) \

 

$$quote($$BASEDIR/..//BBOmnisWrapper/libs/Simulator) \

 

 

To test things I manually added

 

OMNISLIBDIR = $$quote($$_PRO_FILE_PWD_)

 

 

-L$$quote($$OMNISLIBDIR/libs/Simulator/libBB10Lib)

 

To the .pro file to see if it can find it by forcing a path and it finds it ok.

I will probably have to mod the pro file to determin the build and select the lib depending..  Shame I cannot leave it to the pri as intended but there seems to be a fault with it.

 

I am however experiencing another issue ontop of this and that is when it can find the lib it is still not able to find the functions in the library.  I am going to have to read up on building a static link library again as I was stupid enough to believe that creating a static library in the Momentics wizard and building was all that was needed ( LIke on all other development systems )  But clearly there is more work to be done.

 

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Static Library linking

Sorry I thought you were using Managed Project. With yours definitely it is more complex but doable. Good luck. When you fix it you'll see how easy it is -)

Please use plain text.
Contributor
PJDavis1970
Posts: 44
Registered: ‎01-22-2013
My Device: Z10, Q10, Z10 Alpha
My Carrier: None

Re: Static Library linking

Well I have added this to my Pro file.  Not sure if this is a good thing to do or not but hey :smileyhappy:

 

LIBS +=  -lbbdata -lbbpim -lbbdevice -lcamapi -lscreen  -lbbsystem  -lbbcascadesmultimedia -lzxing -lbbmultimedia -lmmrndclient -lasound -lbbplatform -lQtLocationSubset  -lbbcascadesmaps -lGLESv1_CM -lexif -lbb \

device {
    CONFIG(debug, debug|release) {
    	LIBS += -L$$quote($$OMNISLIBDIR/libs/Device-Debug/libBB10Lib)  
    }
    CONFIG(release, debug|release) {
		LIBS += -L$$quote($$OMNISLIBDIR/libs/Device-Release/libBB10Lib)  
    }
}

simulator {
    CONFIG(debug, debug|release) {
		LIBS += -L$$quote($$OMNISLIBDIR/libs/Simulator-Debug/libBB10Lib) 
    }
}

 What I am now getting though is that the Device release build seems to be working ok but both Device Debug and Simulator Debug are failing to find the functions within the lib.  Going to have to look into whats going on.

Please use plain text.
Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Static Library linking

Please use plain text.
Contributor
PJDavis1970
Posts: 44
Registered: ‎01-22-2013
My Device: Z10, Q10, Z10 Alpha
My Carrier: None

Re: Static Library linking

Well I have partially fixed my issues.  It seems there was an issue with library path in the pro file.

 

I have now used this.

 

OMNISLIBDIR =  ../libs

CONFIG += qt warn_on cascades10

CONFIG += mobility
CONFIG += console

MOBILITY += sensors

LIBS +=  -lBB10Lib -lbbdata -lbbpim -lbbdevice -lcamapi -lscreen  -lbbsystem  -lbbcascadesmultimedia -lzxing -lbbmultimedia -lmmrndclient -lasound -lbbplatform -lQtLocationSubset  -lbbcascadesmaps -lGLESv1_CM -lexif -lbb 


INCLUDEPATH += $${OMNISLIBDIR}             

device {
    CONFIG(release, debug|release) {
    	LIBS += -L$${OMNISLIBDIR}/Device-Release   
    }
    CONFIG(debug, debug|release) {
    	LIBS += -L$${OMNISLIBDIR}/Device-Debug  
    }
}

simulator {
    CONFIG(debug, debug|release) {
    	LIBS += -L$${OMNISLIBDIR}/Simulator-Debug   
    }
}

 

However I still seem to have one problem.  I have build 3 versions of the library.

 

Device-Debug

Device-Release

Simulator-Debug

 

All 3 versions build ok with no link errors or anything.  The Simulator-Debug works fine on the simulator.  The Device-Debug works fine on teh device.  However the Device-Release builds ok but when I attempt to run it on the Z10 I get "Unable to release application to target"

 

The app writes to the device ok and attempts to run.  The slash screen shows for a split second and then the app terminates.

 

Has anyone else come accross this and did you find a resolve?

 

Thanks

Please use plain text.
Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Static Library linking

Do you have all of the configurations set up in your bar-descriptor.xml?

Please use plain text.
Contributor
PJDavis1970
Posts: 44
Registered: ‎01-22-2013
My Device: Z10, Q10, Z10 Alpha
My Carrier: None

Re: Static Library linking

[ Edited ]

After some more testing and going a bit more grey haired I have figured out what was going on.

 

It turns out that one of my c++ classes was preventing the release build working.  So there seems to be nothing wrong with my library or linking.

 

I have seen things like this before over the years.  I believe the debug information linked into the final app was allowing the bugged class to run without causing read / write memory issues or what ever it was but when trying to run the release build the bug is immediatly showing up.

 

I have yet to track down the actual bug in the class but I have temporarily removed it from the lib and added it to the main project and all seems to be working.  Will keep fingers crossed QA dont come back with anything while I track down this class bug :smileyhappy:

 

Thanks for input form everyone.

Please use plain text.