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
Posts: 23
Registered: ‎05-29-2012
My Device: PlayBook
My Carrier: NA
Accepted Solution

Confusion regarding the two c++ libs included with the NDK

[ Edited ]

Hiya,

 

There seem to be two sets of c++ libraries available with the NDK (I'm using 2.0.1): the "Dinkum" libs, which are clearly mentioned and documented (and included by default with C/C++ projects in Momentics), and the GNU libs. Both are also present on the simulator as well.

 

Why are there two sets of libs?

 

I've also noticed that if I link any of my apps specifically against the GNU libs (libstdc++), they'll crash! Should this be happening? Can we somehow choose which one to use when the application is run?

 

It'd be really nice if we could use libstdc++ -- a lot of the stuff I want to port over takes advantage of the new c++0x containers.

Retired
Posts: 19
Registered: ‎05-07-2012
My Device: none
My Carrier: none

Re: Confusion regarding the two c++ libs included with the NDK

Hey canurabus,

It seems that the Dinkum libs have dependencies on the GNU libs included. When linking directly to the GNU libs did you change your runtime to GNU (right click Project -> Properties -> c/c++ Build -> settings). It's unlikely to get the new c++0x since bbndk-2.0.1 is using gcc 4.4.2, you may want to consider moving to bbndk-10.0.4-beta since it is using gcc 4.6.3

Cheers,

Tim

Developer
Posts: 23
Registered: ‎05-29-2012
My Device: PlayBook
My Carrier: NA

Re: Confusion regarding the two c++ libs included with the NDK

[ Edited ]

Hold on -- why would you say the Dinkum libs have deps on the GNU ones? This seems wrong.

 

Also, GNU libs already supports some of c++0x. You can look at the new container class headers (unordered_map, unordered_hash) in the tool chain target dir. In fact I ran a sample program involving some c++0x stuff and it works fine. I realized that the libstdc++ programs seem to crash when I'm also linking to Qt, but otherwise work fine (so far). I've reported this a bunch of places but have yet to hear back, or even get a confirmation that there's an actual problem and it's not an environment/setup kind of thing.

Retired
Posts: 19
Registered: ‎05-07-2012
My Device: none
My Carrier: none

Re: Confusion regarding the two c++ libs included with the NDK

I miss typed when saying they have dependencies on each other, I meant there seems to be dependencies on both sets of libs. Are you able to get Qt working without linking to libstdc++? If not it's possible that Qt is unable to locate some dependencies, or is possibly linking to the incorrect libs. Have you tried running ldd on the Qt libs to find any dependencies?

Developer
Posts: 23
Registered: ‎05-29-2012
My Device: PlayBook
My Carrier: NA

Re: Confusion regarding the two c++ libs included with the NDK

I think the dependencies are satisfied. You may be right about the libs being incorrect but the output from ldd seems to be okay:

 

// sample lib from qcc makespec (works!)
ldd libQtCore.so.4
  linux-gate.so.1 =>  (0xf7732000)
  libm.so.2 => not found
  libbps.so.3 => not found
  libz.so.2 => not found
  libiconv.so.1 => not found
  libcpp.so.4 => not found
  libc.so.3 => not found

// sample lib from my terrible makespec (doesn't work)
ldd libQtCore.so.4
  linux-gate.so.1 =>  (0xf7789000)
  libbps.so.3 => not found
  libz.so.2 => not found
  libm.so.2 => not found
  libiconv.so.1 => not found
  libstdc++.so.6 => /usr/lib32/libstdc++.so.6 (0xf736e000)
  libc.so.3 => not found
  libm.so.6 => /usr/lib32/libm.so.6 (0xf7340000)
  libc.so.6 => /usr/lib32/libc.so.6 (0xf719d000)
  /lib/ld-linux.so.2 (0xf778a000)
  libgcc_s.so.1 => /usr/lib32/libgcc_s.so.1 (0xf7182000)

I'm iffy about "libgcc" since I don't see that in the NDK. I don't even know what libgcc is... and google wasn't too helpful. Running grep through the NDK shows that the libstdc++ shared libs match that search string, but their only deps are libm and libc. 

Retired
Posts: 19
Registered: ‎05-07-2012
My Device: none
My Carrier: none

Re: Confusion regarding the two c++ libs included with the NDK

Several of the deps seem to be system libs.

 

libstdc++.so.6 => /usr/lib32/libstdc++.so.6 (0xf736e000)
...
libm.so.6 => /usr/lib32/libm.so.6 (0xf7340000)
libc.so.6 => /usr/lib32/libc.so.6 (0xf719d000)
...
libgcc_s.so.1 => /usr/lib32/libgcc_s.so.1 (0xf7182000)

 

That may cause an issue since they weren't built for the device. Those should probably be linking to the platform specific libs.

Developer
Posts: 23
Registered: ‎05-29-2012
My Device: PlayBook
My Carrier: NA

Re: Confusion regarding the two c++ libs included with the NDK

I could be wrong, but I don't think those paths represent what's being linked to by the final binary. The shared lib compiled with the gnu tools has libstdc++.so.6, and so does my system. I think ldd just resolves the names of those libs using my local system paths; on my system libstdc++ in turn depends on libm.so.6 and and libc.so.6 (and libgcc_s I guess) which is why they're listed as well. If you run ldd from another system on the same file for example, it'll return similar output with its own local paths.

 

If you run readelf on the binary, you'll see it has the right versions.

 

Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libQtDeclarative.so.4]
0x00000001 (NEEDED) Shared library: [libQtScript.so.4]
0x00000001 (NEEDED) Shared library: [libQtSvg.so.4]
0x00000001 (NEEDED) Shared library: [libQtSql.so.4]
0x00000001 (NEEDED) Shared library: [libQtXmlPatterns.so.4]
0x00000001 (NEEDED) Shared library: [libQtNetwork.so.4]
0x00000001 (NEEDED) Shared library: [libsocket.so.3]
0x00000001 (NEEDED) Shared library: [libQtOpenGL.so.4]
0x00000001 (NEEDED) Shared library: [libQtGui.so.4]
0x00000001 (NEEDED) Shared library: [libQtCore.so.4]
0x00000001 (NEEDED) Shared library: [libbps.so.3]
0x00000001 (NEEDED) Shared library: [libGLESv2.so.1]
0x00000001 (NEEDED) Shared library: [libEGL.so.1]
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
0x00000001 (NEEDED) Shared library: [libm.so.2]
0x00000001 (NEEDED) Shared library: [libc.so.3]
...

 The paths to these libs should be resolved at run time on the device, which seems to be happening.

Retired
Posts: 19
Registered: ‎05-07-2012
My Device: none
My Carrier: none

Re: Confusion regarding the two c++ libs included with the NDK

Have you tried adding the Modules view (Window->Show View->Modules) to Momentics to see which modules are getting loaded when the applications is run?

Retired
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: Confusion regarding the two c++ libs included with the NDK

Does your reply to http://supportforums.blackberry.com/t5/Native-Development/Desperate-for-help-with-simple-program-cra... also apply to this?

Can we close this thread until you hear back about the bug, or is there a separate issue here?

 

Stuart

Developer
Posts: 23
Registered: ‎05-29-2012
My Device: PlayBook
My Carrier: NA

Re: Confusion regarding the two c++ libs included with the NDK

Yeah, sorry. Both threads are related; feel free to close both.