這是我第一次使用android NDK和Cygwin,我正在使用Windows XP 32位,如果有任何幫助的話。Android NDK - 鏈接問題
我試圖移植在Windows和Linux上使用它的一個Visual Studio 8項目在Android平臺上使用它。 該項目是相當大的,並在多個文件夾的文件...
當試圖用NDK建造建造它,我得到了很多這些類型的錯誤:
D:/android-ndk-r8d-windows/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/ndkmain/.o: in function Version:jni/.cpp:75: error: undefined reference to 'get_version(long*, long*, long*, long*)'
在這個例子中,在這裏是我MYFILE.CPP
#include "../KERNEL/Include/Get_Version.h"
long Version (long *a,
long *b,
long *c,
long *d)
{
if(get_version(a, b, c, d) == -1)
return(IDP_ERR_POINTER);
return (IDP_CORRECT);
}
get_version(長*,長*,長*,長*)公在Get_Version.h頭限定,並且所述報頭Get_Version.h發現
個Get_Version.h:
#ifndef GET_VERSION_H_
#define GET_VERSION_H_
int get_version(long *a, long *b, long *c, long *d);
#endif //#define GET_VERSION_H_
Get_Version.cpp:
#include <stdlib.h>
#include "../Include/Get_Version.h"
int get_version(long *a, long *b, long *c, long *d)
{
if (a == NULL){ return -1;}
if (b == NULL){ return -1;}
if (c == NULL){ return -1;}
if (d == NULL){ return -1;}
*a = 3;
*b = 1;
*c = 8;
*d = 2;
return (0);
}
如果相反的鏈接我的源代碼文件的#include」 ../KERNEL/Source/Get_Version鏈接的標題。 CPP「該錯誤消失,但我想避免這種情況,因爲這將是不好的做法...
我的猜測是,編譯器無法鏈接Get_Version.c函數的定義PP到Get_Version.h中的聲明,但我不知道如何強制與android ndk和cygwin的這個鏈接...
感謝您的任何幫助。
PS:這裏是我的.mk文件
Android.mk
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:=ndkmain
LOCAL_SRC_FILES :=<MyFolder>/<MyFile>.cpp
include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_STL :=stlport_shared
APP_ABI:= armeabi-v7a
我會測試,謝謝你爲了那個快速的回答。 – user1471450 2013-04-25 12:55:32
它似乎解決了我的問題,但是我需要將每個單獨的一個cpp文件添加到Android.mk?謝謝 – user1471450 2013-04-25 13:00:12
是的。這就是你如何告訴Android構建系統需要構建的內容。 – 2013-04-25 13:33:55