使用NDK为Android构建C / C ++可执行文件失败

时间:2015-09-18 12:29:45

标签: android android-ndk

t_proj.c如下:

#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("Hello, World!\n");
    return 0;
}

我的Android.mk如下:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE   := t_proj
LOCAL_SRC_FILE := t_proj.c

include $(BUILD_EXECUTABLE)

在使用ndk-build进行编译时,出现以下错误:

[armeabi] Executable     : t_proj
/usr/local/Cellar/android-ndk/r10e/platforms/android-3/arch-arm/usr/lib/crtbegin_dynamic.o:crtbrand.c:function _start: error: undefined reference to 'main'
collect2: error: ld returned 1 exit status
make: *** [/Users/[USER]/t_proj/obj/local/armeabi/t_proj] Error 1

1 个答案:

答案 0 :(得分:1)

尝试修改Android.mk

LOCAL_SRC_FILES := t_proj.c