cygwin - Android NDK - Linking issue -
that's first time using android ndk , cygwin, i'm working on windows xp 32bits if thats of help.
i trying port visual studio 8 project used on windows , linux use on android platform. project quite big , has files in several folders…
when trying build ndk-build, 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 'get_version(long*, long*, long*, long*)'
for example, here 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*) defined in get_version.h header, , get_version.h header 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 header link source file #include "../kernel/source/get_version.cpp" error disappear, avoid since poor practice...
my guess compiler cannot link definition of function in get_version.cpp declaration in get_version.h, not know how force link android ndk , cygwin...
thanks help.
ps : here .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