1

I am trying to build a JNI library to ed25519 I am able to compile the library and my bridge code, but then it fails when trying to merge back using -shared

Those commands works:

  • 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

But then this one fails:

  • g++ -Wl,--add-stdcall-alias -shared -o Core/out/jni/ed25519.dll Core/out/jni/tmp_java_bridge.dll -m64 -O3

With error message:

undefined reference to `ed25519_publickey'

Here is the file where it fails:

#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;
}
Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216

0 Answers0