Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid NDK - Linking issue
    primarykey
    data
    text
    <p>That's my first time using the android NDK and Cygwin, I'm working on Windows XP 32bits if thats of any help.</p> <p>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…</p> <p>When trying to build it with ndk-build, I get a lot of error of these kind : </p> <blockquote> <p>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*)'</p> </blockquote> <p>For this example, here is my MyFile.cpp</p> <pre><code>#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); } </code></pre> <p><strong>get_version(long*, long*, long*, long*)</strong> is well defined in the Get_Version.h header, and the Get_Version.h header is found</p> <p>Get_Version.h :</p> <pre><code>#ifndef GET_VERSION_H_ #define GET_VERSION_H_ int get_version(long *a, long *b, long *c, long *d); #endif //#define GET_VERSION_H_ </code></pre> <p>Get_Version.cpp :</p> <pre><code>#include &lt;stdlib.h&gt; #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); } </code></pre> <p>If instead of linking the header I link the source file with <strong>#include "../KERNEL/Source/Get_Version.cpp"</strong> The error disappear, but I would like to avoid this since it would be poor practice...</p> <p>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...</p> <p>Thanks for any help.</p> <p>PS : here are my .mk files</p> <p>Android.mk</p> <pre><code>LOCAL_PATH:=$(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:=ndkmain LOCAL_SRC_FILES :=&lt;MyFolder&gt;/&lt;MyFile&gt;.cpp include $(BUILD_SHARED_LIBRARY) </code></pre> <p>Application.mk</p> <pre><code>APP_STL :=stlport_shared APP_ABI:= armeabi-v7a </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload