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

Making a Qt/Cascades library

I have the tendency to make libraries instead of actual applications (working on it...). I want to make a library for BlackBerry 10 that uses some of the Qt/Cascades classes and possibly has some Cascades QML elements. The only option I seem to have within Momentics is to make an application. Is there any way to make a library, not an application, that has said support?

---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
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Making a Qt/Cascades library

If you select  File -> New... then "BlackBerry C/C++ Project", you should get a dialog.  Enter a project name, then Next, and on the next page you should see options including "Empty Shared Library" which ought to be configured to produce a .so instead of an executable and .bar file.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
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: Making a Qt/Cascades library

That is what I currently have. But if you do the same for a Cascades project it includes the Qt folders (can do that myself) and seems to have a customized C++ builder setup (that I can't do and is what I am curious in).

In a general sense. If I make a QML file (and add the required Qt includes), will it work? What about stuff like creating Qt classes and moc (meta object compiler)? Will those compile and work (meta data and all)?
---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
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Making a Qt/Cascades library

I can't answer all that, but it seems to me that a library doesn't include QML or other assets (unless it's serialized into the binary for the library), and so it doesn't need much of that. Just needs access to the right header files. And maybe something with the MOC stuff, though I'm too new to that area to know quite how it all works.

(My understanding of it is that it creates some additional source which qmake compiles in transparently, and that ends up adding the required metadata to let the various QObject subclasses register themselves in the "Meta-Object System". That would presumably be code that needs to be included in the library, so therefore it would need the MOC stuff to all be available and build time too.)

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
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: Making a Qt/Cascades library

With the QML, I'm used to Android and WPF where it compiles into a binary. If it simply includes it as an asset, then I know libraries will support that.

So then it goes to the Qt/MOC stuff. What do I have to do differently to make a library that has QObjects and meta-data (produced by MOC/qmake)?
---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.
Contributor
mkristell
Posts: 22
Registered: ‎01-24-2011
My Device: Not Specified

Re: Making a Qt/Cascades library

I wanted a static library that made use of Qt classes. I tried the "create library" wizard in Momentics IDE release 10.0.4. The library built fine but when trying to use the library from my app I got linking error on all classes inheriting from QObject. This is likely to be because moc.exe wasn't run on the library during the build.

 

As a workaround I created the library with the steps below. I don't know if they are recommendable but it seems to work.

 

  1. Create a new BlackBerry Cascdes C++ project
  2. Manually edit the .pro file, change TEMPLATE from app to lib and add staticlib to CONFIG if you want a static library.
  3. Above changes are enough for the tool chain to produce a library  instead of an app. Unfortunately, you can not use Eclipse to include this library into your app, so in your app's .project you need to locate <projects></projects> and add your library as <project>libraryname</project> in there.
  4. Then in your app's .pro file
    1. add a LIBS += -llibraryname
    2. add relative path to your library's headers using INCLUDEPATH+=
    3. in the relevant CONFIG(release, debug|release) sections, add LIBS += -Lrealtivepathtobinary
  5. (If you add a shared library you need to add it to the BAR file as well)
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: Making a Qt/Cascades library

That looks pretty good. I will try it when I get the chance, which may be tomorrow.

One thing, what do you mean "you can not use Eclipse to include this library into your app's project" Where would I even add it?

I usually just specify the library path, library name, and where to look for header files. Is there some addition step/replacement procedure that I didn't know about?
---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.
Contributor
mkristell
Posts: 22
Registered: ‎01-24-2011
My Device: Not Specified

Re: Making a Qt/Cascades library

This procedure to add a library using the Momentics IDE "doesn't work" (the library doesn't show up in the wizard):
In the Project Explorer view, right-click a project in the IDE and select configure > Add Library
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: Making a Qt/Cascades library

O, that. I never used that so I guess I shouldn't have an issue?
---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: Making a Qt/Cascades library

Though I wish there was a more "offical" way, it works as desired.
---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.