Suhail Gupta
Suhail Gupta

Reputation: 23276

Why do i get this error?

AFTER EDIT

I get the this error

1>     Creating library D:\Jni tester\Debug\Jni tester.lib and object D:\Jni tester\Debug\Jni tester.exp
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>D:\Jni tester\Debug\Jni tester.exe : fatal error LNK1120: 1 unresolved externals

when i run the following code :

#include <jni.h>
#include <stdio.h>
#include "HelloWorld.h"

JNIEXPORT void JNICALL 
 Java_HelloWorld_print( JNIEnv *env , jobject obj) {
printf("Hello World!\n");
return;
 }

This is the header file HelloWorld.h

/* 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:    print
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_HelloWorld_print
(JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif

Why do i get this error ?

Upvotes: 0

Views: 252

Answers (1)

MByD
MByD

Reputation: 137382

JNIENv should be JNIEnv (lower case n) as shown by this Getting Started guide.

Edit: As seems from your error, you should define the project as a DLL, in your case it looks for the main method since it tries to create an executable.

Upvotes: 3

Related Questions