I'm trying to get familiar with the JNI API but can't get a sample c++ program to compile. I got the same sample to compile and run in linux (after posting the question in the link below) but can't get it compiled in windows; I'm using mingw g++. I've changed all the include paths to windows paths and the jni.h is being located at compile time but not the jvm.dll.
undefined reference to `JNI_CreateJavaVM' linux
Here is the commands I've tried using to compile:
g++ -g -I"C:\Program Files (x86)\Java\jdk1.7.0_21\include" -I"C:\Program Files (x86)\Java\jdk1.7.0_21\include\win32" -L"C:\Program Files (x86)\Java\jdk1.7.0_21\jre\bin\server" callJava.cpp -ljvm
and...
**same as above with the additional** : -L"C:\Program Files (x86)\Java\jdk1.7.0_21\lib"
The error I get is:
undefined reference to `_imp__JNI_CreateJavaVM@12'
and the cpp being compiled:
#include <jni.h>
int main(){
    //firstTest();
    JavaVM *jvm;
    JNIEnv *env;
    JavaVMInitArgs vm_args;
    JavaVMOption options[1];
    options[0].optionString = "-Djava.class.path=C:/Users/Ron/Dropbox/jni/simple/ctojava/win";
    vm_args.version = JNI_VERSION_1_6;
    vm_args.options = options;
    vm_args.nOptions = 1;
    vm_args.ignoreUnrecognized = JNI_FALSE;
    int res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
    jclass cls = env->FindClass("Hello");
    jmethodID mid = env->GetStaticMethodID(cls, "staticInt", "(I)I");
    env->CallStaticVoidMethod(cls, mid,10);
    jvm->DestroyJavaVM();
}
I've looked at many examples but still can't find a solution. Any help is appreciated!
UPDATE: I am pretty sure the the jvm.dll is being located because if I remove the -L"path_to_jvm" then I get the error:
mingw32/bin/ld.exe: cannot find -ljvm
Like I said, this exact approach works in linux, What else am I missing for windows?