Navigating source for linked libraries.

69 views
Skip to first unread message

Blake Meike

unread,
Sep 30, 2022, 12:46:17 PMSep 30
to android-ndk
My project has a NDK layer that is the glue to a C++ library.  My JNI code compiles against the header files for that library and I load the library at runtime (System.loadLibrary).  The library itself is provided to me as a single .so file.

Android Studio allows me to navigate into the JNI code.  When I try to navigate into the library, though (Go to Declaration), I am, unsurprisingly, sent to the .h file.

Similarly, when debugging, as soon as I descend into the library, I can no longer see the corresponding source.

I have access to the sources for the library.  Is there any way that I can attach those sources so that
  • Navigation works: Go to Declaration shows two choices: the .h definition and the .cc definition
  • Debugging shows the corresponding source: When I'm debugging, I can see the source, add breakpoints in the source, etc.

r0l...@freemail.hu

unread,
Oct 5, 2022, 3:23:29 PMOct 5
to android-ndk
I recently got into the same situation as the standalone ndk toolchain produces a lib that crashes on unwind. The only solution that worked for me on windows was to copy the cpp sources and headers to a directory (in my case src/main/cpp) as there's no symlink on windows but if you're on linux [or bsd ;)], a directory with a symlink would do I think. You also have to include that directory in CMakeLists [for me it is: include_directories(src/main/cpp)] and list those cpp files in your JNI library section. Here's a screenshot of what I did in cmake(along with my notes for myself about the steps):

cmakelists_with_cpp_files.JPG

Blake Meike

unread,
Oct 6, 2022, 12:37:42 PMOct 6
to android-ndk
Isn't that going to make CMake try to build it???

r0l...@freemail.hu

unread,
Oct 7, 2022, 5:59:48 AMOct 7
to android-ndk
Yes, this way CMake will build the native c++ code.

Blake Meike

unread,
Oct 7, 2022, 2:12:51 PMOct 7
to android-ndk
Yeah... that won't work. That will just make the build fail.  While I have source for the library on which I depend, I have neither source nor artifacts for its dependencies.

Blake Meike

unread,
Oct 7, 2022, 2:37:21 PMOct 7
to android-ndk
Yeah...thanks, but that is not a solution.  While I have the source for the library on which I depend, I don't have the artifacts necessary to build it.

On Friday, October 7, 2022 at 2:59:48 AM UTC-7 r0l...@freemail.hu wrote:

r0l...@freemail.hu

unread,
Oct 13, 2022, 3:59:39 PMOct 13
to android-ndk
Yepp, that's tough. In my case, all my dependencies are open source so I could cross compile them for arm.
Reply all
Reply to author
Forward
0 new messages