Reputation: 2456
Hi I am creating an openssl wrapper c library to be use with JNI. My c source file name is rsa.c and JNI header file name is OpensslRSA.h which is contain in both JAVA_HOME/include and JAVA_HOME/include/linux directories. I am using below syntax to create this library .
gcc -shared -fpic -o librsa.so -I/usr/local/jdk1.7.0_45/include -I/usr/local/jdk1.7.0_45/include/linux rsa.c
This c program uses below header files
#include <jni.h> #include <stdio.h> #include <OpensslRSA.h> #include <openssl/pem.h> #include <openssl/ssl.h> #include <openssl/rsa.h> #include <openssl/evp.h> #include <openssl/bio.h> #include <openssl/err.h>
but when I use this from java program as below
java -Djava.library.path=/home/agarwal/test/c_tests/opensslrsalib OpensslRSA
then it give below error
java: symbol lookup error: /home/agarwal/test/c_tests/opensslrsalib/librsa.so: undefined symbol: BIO_new_mem_buf
Can any body let me know what should I do for this as all the header files used exist in /usr/include as per there use in c source
Upvotes: 0
Views: 514
Reputation: 2173
BIO_new_mem_buf is in the openssl library. You have to link your library with -lcrypto
(lower case L) or with what pkg-config --libs openssl
gives you.
Upvotes: 1