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
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon
Accepted Solution

Shared Libraries

I'm having some issues with making a shared library, or libraries in general.

 

Issue #1

I create a shared library project, header, code, etc. Build the project and... nothing. According to my console:

Build error
Generated resource conflict:
two resources of the same name: /sharedLib/Device-Debug/src/codeFileInSharedLib.o
generated by different tools
tool1: QCC Compiler
tool2: QCC Compiler

 

I can't find anything on this but it's giving me headaches and refuses to compile.

 

This brings up issue #2, I actually did manage to get the project to compile (when it was smaller and more basic) but encountered another issue when I tried to link it to a project:

cannot find -lsharedLib

 

Now based on what I got from the beta forums:

elenalaskavaia:

Depends what project type you have, normally you don't want to link again .o file, you should create a library and link with library. You can create a static library project called myboost, copy you source there.
If this a managed project it will be all set you just have to build it. It will produce libmyboost.a file

In the project that using it you have to specify few things - that a) you want to link to that library  b) where to find it c) where to find headers for this library d) if you want you can specify project dependency, so if you change library you binary project will be automatically recompiled


Docs for managed projects set-up

--------------------------------

For manage projects (both main and library are managed projects).

Main project is aaa and library is bbb.


* Specify library and library path in linker
In aaa project properties->C/C++ Build->Settings->QCC Linker->Libraries

- Select "All configurations" in Configuration drop down at the top of the
window
- In library path add ${workspace_loc:/bbb}/${ConfigName} (Click add icon)
(variable with $ are verbatim, bbb is the project name which changes)

- In libraries, click Add and add you library name, i.e. bbb


* Specify includes
- Switch to Qcc Compiler->Preprocessor on the left

- Add include folder ${workspace_loc:/bbb/src} (assuming public headers for bbb
library in src folder of bbb project
In aaa project properties->C/C++ General->Paths and Symbols->Referebces tab


* Specify dependency
- In configurations select your active configuration (on top)

- Expand bbb project and select matching configuration

- Unfortunately you have to repeat it for all configurations you use (Select
Configuration on top, then check reference to matching configuration in bbb
project)
Press Apply and close the dialog

 

I was able to get the project to link but this seems a little more temperamental (as if I change a library in "C/C++ General" project property, it clears the libraries set within "C/C++ Build".

 

Finally, the issue I have not encountered yet, issue #3:

How does one actually create an application that uses a shared library, because shared libraries are not supported (in the sense of load a single library and everyone can access it). Will the release build (which creates a BAR) add the library to it or do I need to do something extra?

 

So after all that, any advice or solutions?

 

I assume I would have to do the same thing for a static library?

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Shared Libraries

Ok, I managed to get Issue #1 to go away (which caused issue #2 to go away, expectedly). But the instant I went to work on it and then compile, issue #1 came back up (and caused issue #2 to come back up, again, expectedly).

 

I double checked all configurations based on what was mentioned in the Beta Forums, and everything seems correct. So I don't know what is going on.

 

Unrelated, Momentics/QCC doesn't like multiple source folders. Complains that it can't find files that are located in the other source folder, like includes.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Shared Libraries

*facepalm* Ok, nevermind. Didn't realize that I had 2 source code files with the same name. Issue #1 and #2 fixed. I'll leave the thread open if anyone knows the answer to issue #3.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
BlackBerry Development Advisor
elena_laskavaia
Posts: 417
Registered: ‎10-27-2010
My Device: PlayBook

Re: Shared Libraries

You create shared library i.e. .so file. You package it in your sandbox (i.e. add to assets of your app as "shared library").

It will be loaded by your app in runtime. The only diffrence it is not really "shared" per se, only your app can access it.

Creating an applications which would actaully share the libraries is not supported by platform yet.

Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Shared Libraries

Ok, that is what I assumed. Thank you.
---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
KenSalmon
Posts: 114
Registered: ‎08-09-2010
My Device: Tour
My Carrier: Bell

Re: Shared Libraries

 

I was able to get the project to link but this seems a little more temperamental (as if I change a library in "C/C++ General" project property, it clears the libraries set within "C/C++ Build".

 

_________________________________________________________________________

 

I've just now had something similar happen...trying to set up an app with reference to a shared library. On each properties page I modified, I made sure to Apply then OK before going on to the next page, just to be extra careful that I wouldn't lose any changes.

 

At some point, the entirety of the app's C/C++ Build -> Settings -> QCC Linker -> Libraries -> Library Paths (-L) got wiped out, including the default paths that were setup when the project was created. I can't be sure exactly what order things we done, in order to have those properties wiped out. (I just know that I didn't delete them!)

Please use plain text.
BlackBerry Development Advisor
elena_laskavaia
Posts: 417
Registered: ‎10-27-2010
My Device: PlayBook

Re: Shared Libraries

If you use managed project only set libraries using C/C++ Build, the one for non-managed project to set up for indexer (which is CDT parser for code navigation and such)

Please use plain text.