Am just starting learn jni and decided to do a hello world. i created a helloworld java file whose code is
public class HelloWorld {
public native void displayHelloWorld();
static{
System.loadLibrary("hello");
}
public static void main(String[] args){
new HelloWorld().displayHelloWorld();
}
}
and i compiled it to get the following header file
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class HelloWorld */
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: HelloWorld
* Method: displayHelloWorld
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
followed by creating a c file whose code is
#include<jni.h>
#include "HelloWorld.h"
#include <stdio.h>
JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj){
printf("Hello World \n");
return;
}
and compiled it to create the helloworld.o file
and now when i tried to create the .dll file using the command
gcc -shared -o hello.dll HelloWorld.o -Wl,--add-stdcall-alias
i get this error
At line:1 char:42
+ gcc -shared -o hello.dll HelloWorld.o -Wl,--add-stdcall-alias
+ ~
Missing argument in parameter list.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingArgument
what am i missing?