Issue
Just build a simple "helloworld" using android ndk, but I got shard object which I supposed to get executable file. And after I pushed this file to my arm emulator, I got a segmentation fault, but real device is OK. What's the problem?
Here is my os version:
Darwin avator 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64 i386 MacBookPro11,1 Darwin
Here is my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := test-libstl
LOCAL_SRC_FILES := test-libstl.cpp
include $(BUILD_EXECUTABLE)
And after ndk-build,I got the file:
$file ../libs/arm64-v8a/test-libstl
../libs/arm64-v8a/test-libstl: ELF 64-bit LSB shared object, version 1 (SYSV), dynamically linked (uses shared libs), stripped
Solution
This is not an error in itself - it's only the file utility which interprets a position independent executable (PIE) as a shared object - your executable has been built just fine.
Only Android 4.1 and newer supports PIE executables, and on 5.0, non-PIE executables aren't allowed any longer - this may be why you can't run it in the emulator. See Running a native library on Android L. error: only position independent executables (PIE) are supported for more details on this issue. If your target platform in the NDK is Android 4.1 or newer (android-16), executables will be built with PIE enabled.
Answered By - mstorsjo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.