Below is the code I'm using and the compile command. I'm somewhat new to c++ and don't really know how to go about debugging a segmentation fault, doesn't really give much info. Any advice would be much appreciated!
#include <jni.h> /* where everything is defined */
int main() {
JNIEnv *env1;
JavaVM** jvm1;
JavaVMInitArgs vm_args1;
JavaVMOption options1[3];
options1[0].optionString = "-Djava.library.path=/usr/lib/jvm/java-7-oracle/jre/lib/amd64/server/";
options1[1].optionString = "-Djava.class.path=.";
options1[2].optionString = "-Dulimit -c unlimited";
options1[0].extraInfo = NULL;
options1[1].extraInfo = NULL;
options1[2].extraInfo = NULL;
vm_args1.version = JNI_VERSION_1_6;
vm_args1.nOptions = 3;
vm_args1.options = options1;
vm_args1.ignoreUnrecognized = 0;
int reAt = JNI_CreateJavaVM(jvm1, (void**)&env1, &vm_args1);
return 0;
}
As far as I can tell the line causing the problem is the JNI_CreateJavaVM line, when commented out there is no segmentation fault
To compile have tried both of these:
g++ -g main.cpp -I/usr/lib/jvm/java-7-oracle/include -I/usr/lib/jvm/java-7-oracle/include/linux -L/usr/lib/jvm/java-7-oracle/jre/lib/amd64/server -ljvm
g++ -I /usr/lib/jvm/java-7-oracle/include -I /usr/lib/jvm/java-7-oracle/include/linux/ -L /usr/lib/jvm/java-7-oracle/jre/lib/amd64/server main.cpp -l jvm -Wl,-rpath,/usr/lib/jvm/java-7-oracle/jre/lib/amd64/server -o a2.out
Aucun commentaire:
Enregistrer un commentaire