Cross compiling static C hello world for Android using arm-linux-gnueabi-gcc
sudo apt-get install gcc-arm-linux-gnueabi
#include <stdio.h>
int main(int argc, char** argv) {
printf("hello world\n");
return 0;
}
arm-linux-gnueabi-gcc -static -march=armv5 hi.c -o hi
arm-none-linux-gnueabi-gcc -o hello -static hello.c
adb push hi /data/hi
adb shell /data/hi
http://stackoverflow.com/questions/9324772/cross-compiling-static-c-hello-world-for-android-using-arm-linux-gnueabi-gcc
안됨-_-
Android-NDK 다운로드
http://developer.android.com/tools/sdk/ndk/index.html
7z으로 압축해제
/usr/android-ndk 로 옮김
# mv ~Document/android-ndk/ /usr/android-ndk
.bashrc 에 PATH 등록
export PATH="/usr/android-ndk:$PATH"
환경설정 재 등록
# sourc .bashrc
추가 잘되었는지 확인
# $PATH
테스트 실행
# ndk-build
아래 메세지가 나오면 path 설정 완료
Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
/usr/android-ndk/build/core/build-local.mk:148: *** Android NDK: Aborting . Stop.
프로젝트 생성
jni 디렉토리 생성
[Android.mk]
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := hello LOCAL_SRC_FILES := hello.c include $(BUILD_EXECUTABLE)
[hello.c]
#include <stdio.h> int main() { printf("hello ARM android!\n"); return 0; }
$(BUILD_EXECUTABLE) -> 컴파일 될 바이너리를 실행파일로
빌드 전
jni/Android.mk
jni/hello.c
# ndk-build
oneandonlyme@ubuntu:~/Documents/android-dev$ ndk-build [armeabi] Compile thumb : hello <= hello.c [armeabi] Executable : hello [armeabi] Install : hello => libs/armeabi/hell
..?
'00. > 01. C, C++' 카테고리의 다른 글
C++ Hello World (0) | 2014.06.23 |
---|