That's my first time using the android NDK and Cygwin, I'm working on Windows XP 32bits if thats of any help.
I am trying to port a Visual Studio 8 project used on Windows and Linux to use it on an android platform. The project is quite big and has its files in several folders…
When trying to build it with ndk-build, I get a lot of error of these kind :
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*)'
For this example, here is my 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(long*, long*, long*, long*) is well defined in the Get_Version.h header, and the Get_Version.h header is found
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);
}
If instead of linking the header I link the source file with #include "../KERNEL/Source/Get_Version.cpp" The error disappear, but I would like to avoid this since it would be poor practice...
My guess is that the compiler cannot link the definition of the function in Get_Version.cpp to the declaration in Get_Version.h, but I do not know how to force this link with the android ndk and cygwin...
Thanks for any help.
PS : here are my .mk files
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
You need:
LOCAL_SRC_FILES :=<MyFolder>/<MyFile>.cpp <MyFolder>/Path/To/Get_Version.cpp