我正在尝试构建一个JNI库到ed25519我能够编译库和我的桥代码,但是当尝试使用-shared
这些命令有效:
g++ -Wall -g -c Core/src/main/jni/ed25519/ed25519.c -I C:/work/OpenSSL/include -o Core/out/jni/ed25519.dll -m64 -O3
g++ -Wall -g -c Core/src/main/jni/ed25519/ed25519_java_bridge.c -I C:/work/OpenSSL/include -I "C:/Program Files/Java/jdk1.8.0_151/include" -I "C:/Program Files/Java/jdk1.8.0_151/include/win32/" -o Core/out/jni/tmp_java_bridge.dll -m64 -O3
然后这个失败了:
g++ -Wl,--add-stdcall-alias -shared -o Core/out/jni/ed25519.dll Core/out/jni/tmp_java_bridge.dll -m64 -O3
显示错误消息:
对`ed25519_publickey'的未定义引用
以下是失败的文件:
#include <jni.h>
#include "ed25519.h"
#include "com_gazman_coco_core_ed25519_Ed25519Wrapper.h"
#if defined(__cplusplus)
extern "C" {
#endif
unsigned char* as_unsigned_char_array(JNIEnv *env, jbyteArray array);
jbyteArray as_byte_array(JNIEnv *env, unsigned char* buf, int len);
JNIEXPORT jbyteArray JNICALL Java_com_gazman_coco_core_ed25519_Ed25519Wrapper_generatePublicKey
(JNIEnv *env, jclass cls, jbyteArray privateKey){
ed25519_public_key pk;
jbyteArray publicKey;
unsigned char * data;
data = as_unsigned_char_array(env, privateKey);
ed25519_publickey(data, pk); // FAILS HERE
publicKey = as_byte_array(env, pk, sizeof(pk));
return publicKey;
}