NDK profiling showing ".so has no symbols" - android-ndk

I am doing NDK profiling for my project using android-ndk-profiler-3.1. I have made changes in Android.mk as follows...
LOCAL_PATH := $(call my-dir)
-include android-ndk-profiler.mk
include $(CLEAR_VARS)
# Module name -------------------------------------------------------
LOCAL_CFLAGS += -O3
TARGET_ARCH_ABI :=armeabi
LOCAL_CFLAGS := -pg
LOCAL_STATIC_LIBRARIES := andprof
LOCAL_LDLIBS += -llog
LOCAL_MODULE := libitv
include $(BUILD_SHARED_LIBRARY)
Application.mk is as follows...
APP_ABI := armeabi
APP_PLATFORM := android-10
I have called monstartup("itv.so"); function in the beginning of the native code and moncleanup(); function in the stop method. And gmon.out file is created successfully.And then I have pasted gmon.out in
D:\android\android-ndk-r6-windows\android-ndk-r6\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin directory.
But when I am trying to read gmon.out using the following command...
D:\android\android-ndk-r6-windows\android-ndk-r6\toolchains\arm-linux-androideab
i-4.4.3\prebuilt\windows\bin>arm-linux-androideabi-gprof D:\InternetTV_FD_Canvas
\libs\armeabi\libitv.so > out.txt
This Error is showing...
arm-linux-androideabi-gprof: file `D:\InternetTV_FD_Canvas\libs\armeabi\libitv.so'
has no symbols
I am not able to make out why this error is coming even I have done everything fine.
Can anybody please help me.
Any help will be appreciated.
Thanks in Advance.

The NDK build process creates 2 libraries, one with symbols and one stripped without. You install the stripped, symbol-less library in your APK, but you need to use the unstripped version with gprof. If you run:
arm-linux-androideabi-gprof D:\InternetTV_FD_Canvas\obj\local\armeabi\libitv.so
... then that should be the correct library.

Related

How do you add APP_CFLAGS to an android makefile

I was able to successfully pass in APP_CFLAGS via eclipse through via the settings' ndk-build command as
ndk-build -B NDK_DEBUG=1 APP_CFLAGS=-DTEST
I have now switched to Android studio and was trying to do it directly in the makefile with the following, but its not taking:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
APP_CFLAGS += -DTEST
LOCAL_SRC_FILES:= test.cpp
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
It builds fine, but my TEST variable is never set in the C++ code.
How can I add it to the makefile?
Or, How can I add it to Android Studio project settings?
You could use LOCAL_CFLAGS for C/C++ code additional flags or LOCAL_CPPFLAGS for C++ code in Android build system.
LOCAL_CFLAGS := -DTEST=1

Linking against included platform lib and headers with Android Studio and custom makefile

I've managed to get Android Studio setup to link against a custom library in jniLibs and compile a shim with it. But, I can't figure out how to link against EGL.
C++ Shim
#include <jni.h>
#include <android/log.h>
#include <EGL/egl.h>
extern "C" {
// Code and stuff
} // End extern
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := faceblaster-engine
LOCAL_SRC_FILES := ../jniLibs/$(TARGET_ARCH_ABI)/libfaceblaster-engine.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := faceblaster
LOCAL_SRC_FILES := gl-tests.cpp
LOCAL_SHARED_LIBRARIES := faceblaster-engine libEGL
include $(BUILD_SHARED_LIBRARY)
I get the following error:
fatal error: EGL/egl.h: No such file or directory
My guess is that it's assuming that EGL/egl.h should also be in app/src/main/jni, and throws the error because it's obviously not in that directory.
However, it does find android/log.h, so it must have some idea of where these are, but it fails out when it's time to grab EGL. Anyone have thoughts on why EGL is not being pulled in?
Thanks in advance for any help!
Turns out, you need a thing called Application.mk in the same directory as Android.mk to define targets and stuff. I just added this to that file, and everything worked as expected:
APP_ABI := armeabi
APP_PLATFORM := android-15

HERE Map armeabi-v7a libraries removed when im adding armeabi file(C library) Is there something missing with my Android.mk file?

Hello i'm new to NDK and C/C++ development with android application. i'm having problem in my android application in compiling android application with c/c++.. I added some custom libraries for my sqlite. Could anyone explain what's happening to my project and is there something that i need to configure with my MK file? i added this to my mk file APP_ABI := armeabi armeabi-v7a
Here is my Android.mk file
APP_PLATFORM := android-8
#WHAT DO I NEED..
APP_ABI := armeabi armeabi-v7a
#TARGET_ARCH = arm
#TARGET_ARCH_ABI = armeabi-v7a
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ExtFunc
LOCAL_SRC_FILES := extension-functions.c
LOCAL_SRC_FILES += sqlite3.c
LOCAL_SHARE_LIBRARIES := sqlite3
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ProximityAPI
LOCAL_SRC_FILES := ProximitySearch.c
LOCAL_SRC_FILES += sqlite3.c
LOCAL_SHARE_LIBRARIES := sqlite3
include $(BUILD_SHARED_LIBRARY)
When i started running my project the armeabi-v7a libraries
automatically removed in compilation.
I used NDK R10b
To make things clear the two library is working in different project but when i combine them it removed my HERE-Map Libraries under the armeabi-v7a in compiling my android application.
Hope someone could help me i'm confused..
Thanks!
APP_ABI should go into your Application.mk file within the jni folder. It might not exist by default so you might have to create one. Also, if you are building only for ARM there is no need to specify that explicitly. If you are looking to target multiple architecture like x86 you could add that to you APP_ABI parameter.

Warning : Overriding commands for target Android Makefile

I've got an issue building my C++ code using NDK r9d, since I try to compile C files using C++ compiler (G++) I've got this warnings :
C:/Android/ndk/build/core/build-binary.mk:393: warning: overriding commands for target
C:/Android/ndk/build/core/build-binary.mk:391: warning: ignoring old commands for target
Before I didn't need to compile with C++ 11 and my C files was compiled with GCC, I had no problems, but since I had LOCAL_CPP_EXTENSION := .cpp .c, this warnings appears (only for C files).
I found that someone else had the same problem (Overriding commands for target Android Makefile) but didn't get any answer.
Here is my files :
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
MY_INC_PATH := ../../..
LOCAL_MODULE := test
LOCAL_CFLAGS := -Werror
LOCAL_CPPFLAGS := -std=c++11
LOCAL_LDLIBS := -ldl -llog -lGLESv1_CM
LOCAL_C_INCLUDES := \
$(MY_INC_PATH)
MY_SRC_PATH := ../../../..
LOCAL_CPP_EXTENSION := .cpp .c
LOCAL_SRC_FILES := \
$(MY_SRC_PATH)/XXX.c \
$(MY_SRC_PATH)/YYY.cpp \
$(MY_SRC_PATH)/ZZZ.cpp
include $(BUILD_SHARED_LIBRARY)
I use NDK r9d and compile with G++ 4.8 and C++ 11 activated. Thanks for your help.
As of r9d, NDK does not provide methods to unassociate .c files from C compiler. You can redefine $$(TARGET_CC), and also set LOCAL_CFLAGS += -std=c++11, and not set LOCAL_CPP_EXTENSION to include .c, but that would be a hack, anyways. So if you cannot rename the files, and do not want to hack your NDK, the cleanest solution would be to simply ignore the warning.

Adding libpng in android ndk project

I've searched a lot of topics about linking libpng to my android ndk project but I've found right answer for my problem and I hope somebody will help me.
This is hierarchy of my project:
jni
different_cpp_files
different_hpp_files
Android.mk
libpng
different_cpp_files
different_hpp_files
Android.mk
Android.mk in libpng folder:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LS_C=$(subst $(1)/,,$(wildcard $(1)/*.c))
LOCAL_MODULE := png
LOCAL_SRC_FILES := \
$(filter-out example.c pngtest.c,$(call LS_C,$(LOCAL_PATH)))
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lz
include $(BUILD_STATIC_LIBRARY)
I suppose that everything is right here..
Android.mk in jni folder:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LS_CPP=$(subst $(1)/,,$(wildcard $(1)/*.cpp))
LOCAL_MODULE := pacman
LOCAL_CFLAGS := -Wno-psabi
LOCAL_SRC_FILES := $(call LS_CPP,$(LOCAL_PATH))
LOCAL_LDLIBS := -landroid -llog -lEGL -lGLESv1_CM -lOpenSLES
LOCAL_STATIC_LIBRARIES := android_native_app_glue png
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
$(call import-module,libpng)
The last line shows that I got libpng like native_app_glue lib(in the directory of android-ndk sources) Now I want to compile libpng from my project. What I need to change in Android.mk file?
i've got another way for you:
Download all files from here and paste it into a new folder anywhere on your system:
https://github.com/julienr/libpng-android
go into the folder and run:
./build.sh
You will get an libpng.a file in [YOUR_FOLDER]/obj/local/armeabi/libpng.a
Copy this file into:
[YOUR_ANDROID_NDK_FOLDER]/platforms/[ALL_FOLDERS_IN_HERE]/arch-arm/usr/lib/
now you can use libpng in all your projects with the simple line:
LOCAL_LDLIBS += -lpng
you only have to include this in your cpp's:
#include <png.h>
Have fun!

Resources