I have built an .so library for my Android program. Now I want to see the assembly code in that .so file in Mac. I tried otool but it outputs
xxx.so: is not an object file
So is there any way to dissect .so file in Mac?
Related
I'm having trouble linking some files to my project. It's an android studio project and I want to link one external file: "Emv_lib.so" (I know that are some questions on how to link .so files, but those are about internal .so files, this is an external one.)
Beside this file, I have an emv_lib.lib and emvIIapi.h (the header file that actually contains the functions that i need to call). I cannot get this to work. I tried with CMakeList, putting the emvIIapi.h file in there, but it comes with the error: "Execution failed for task ':app:configureCMakeDebug'.
C/C++"
I follow some suggestion, to create in src/main the folder jniLibs and put your .so files in there, but it didn't work.
From my undestanding, I have to compile, somehow, either the .so files or the .lib file.
I'm new to android studio, so don't go hard on me. Thank you for your time!
I want to use .so lib file of another project into my own project.
There i am facing some problems i have put the .so file in JNILibs folder.
but the native methods in the .so file did not successfully loaded and give error that the Can not find the corresponding JNI Function.
so how i can solve this problem i have checked different solutions like
Call shared library (.so) methods within Android Studios C files
How do I package .so files into my .aar archive?
but they did not solve my problem.
i have no .cpp file nor .h file.
I have only .so file so how i can solve this problem.
thanks in advance.
I'm new to android studio and am working on an existing project that is using OpenCV. I need to implement CMU's Pocketsphinx for Android, and in following the installation steps they give I have created a jniLibs folder in my /src directory of my project, and placed the appropriate files for pocketsphinx in there.
This is where the problem occurs- when I do this, I suddenly get the following error message:
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.robodoot.dr.facetracktest-2/base.apk"],nativeLibraryDirectories=[/data/app/com.robodoot.dr.facetracktest-2/lib/arm, /data/app/com.robodoot.dr.facetracktest-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libjniopencv_core.so"
I do NOT get this error if I don't have the jniLibs folder in the /src directory, though then of course I get an error from pocketSphinx saying that it can't find it's required .so files.
What's more, after looking through OpenCV's SDK, I noticed there is no such file "libjniopencv_core.so". It doesn't exist anywhere, there are other .so files but none of which with that name. Even if I install all of the armeabi and what not directories from openCV to my new jniLibs folder, I still get this error message.
How can I tell android studio to only load the pocketsphinx jniLibs files, and disregard searching that directory for openCV .so files?
you can do this by adding following code in gradle
android {
...
defaultConfig {
...
ndk {
abiFilters "armeabi-v7a", "x86","armeabi"
}
packagingOptions {
exclude "lib/arm64-v8a/mysofile.so"
}
}
}
replace arm64-v8a/mysofile.so with whatever you want to exclude.
How can I tell android studio to only load the pocketsphinx jniLibs files, and disregard searching that directory for openCV .so files?
You should not disregard an important file. libjniopencv_core.so is required by opencv.
What's more, after looking through OpenCV's SDK, I noticed there is no such file "libjniopencv_core.so".
It must be inside opencv-android-arm.jar together with other important so files.
It's not clear why file conflicts, it should be some issue with gradle. You need to check internals of APK what so files are actually packed inside. Most likely you try to pack different architectures like armeabi and armeabi-v7. You might need to pack .so files from the same architecture.
I have a .o file for a 3rd party library. I do not have the .c files for it, nor can I get access to them. Normally this isn't a problem, I would just add this to the list of files to link in. But I can't find a way to link in a file without compiling it in the NDK without altering the build scripts. Any suggestions?
I found an answer. Pain in the neck, but it works. I had to turn my .o file into a .a file via the program ar, then create a new static module in my Android.mk file to turn it into a library that android could link via LOCAL_STATIC_LIBS.
I have been trying to implement the API for the serial port found the the below web page. I am a beginner in all this and I am sure about what I am looking at:
http://code.google.com/p/android-serialport-api/source/browse/#svn%2Ftrunk%2Fandroid-serialport-api%2Fproject%2Fjni
Questions:
1) The .c files are built how? Do I need to download the NDK? I assume the .c file is run directly by the virtual machine, or what? Or is the executable for the .c the file in the libs directory? If so, how do I utilize the libserial_por.so file?
Thanks!
The .c files are built into a library by running ndk-build in the project directory. You need the NDK.
The .c files are not run directly by the virtual machine, but rather a library is created in the libs directory, which is then loaded along with the SerialPort class.
To use the library, just use the SerialPort class which already has bindings to the library.
C files will be compiled to an ARM binary library with the extension .so by the NDK. Take a look at the NDK Documentation, section "Getting Started with the NDK", to find out how to use it.
Basically, you place your .c files in the jni directory, change Android.mk to specify how to compile them, then run ndk-build to build the library. The resulting lib<name>.so will be placed in the lib directory. You then use your library in the Java project with System.loadLibrary('<name>').
This of course means the library must have a JNI interface for you to be able to use with the Java application, since Android doesn't support JNA yet.
I see though that the code you pointed out is an Android project. To run it, simply run ndk-build in the project directory to build the library, then run the project in an emulator.