Reputation: 609
I am trying to call a simple connection function from native C code using the NDK and JNI. The following is my code:
C code - returns a value
freerdp_ext_connect(const char *host, const char *username,
const char *pass, const char *domain,
int width, int height){}
Java code:
#include <jni.h>
#include <stdio.h>
#include <freerdp/freerdp.h>
jstring Java_com_example_freerdpandroid_FreeRDPActivity_test(JNIEnv* env, jobject javaThis)
{
freerdp_ext_connect("10.123.123.12", "admin", "dsadsad", "", 600, 800);
return (*env)->NewStringUTF(env, "dsfsdf");
}
When trying to compile with cygwin it's giving me this error:
./obj/local/armeabi/objs/freerdp/freerdp.o: In function `Java_com_example_freerdpandroid_FreeRDPActivity_test':
C:\Users\stefan.scerri\workspace\freerdp/jni/freerdp.c:11: undefined reference to `freerdp_ext_connect'
collect2: ld returned 1 exit status
/cygdrive/c/android-ndk/android-ndk/build/core/build-binary.mk:378: recipe for target `obj/local/armeabi/libfreerdp.so' failed
make: *** [obj/local/armeabi/libfreerdp.so] Error 1
Any idea why this is so? I believe it is because of the return value of the C function, however I'm not sure, can someone kindly confirm. Thanks in advance.
Upvotes: 0
Views: 543
Reputation: 61388
Is the freerdp_ext_connect
in a compiled library, by any chance? If so, are you linking to that library when you build your NDK project? To link with a library, place the following into Android.mk:
LOCAL_LDLIBS := -lfoo
And the linker will link against libfoo.a or libfoo.so, whichever is available.
If freerdp_ext_connect
is in a source file - are you compiling that source file? The source file must be listed under LOCAL_SRC_FILES
in Android.mk.
Upvotes: 1