簡體   English   中英

為什么會出現此錯誤?

[英]Why do i get 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

當我運行以下代碼時:

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

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

這是頭文件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

為什么會出現此錯誤?

如本入門指南所示, JNIENv應該是JNIEnv (小寫n)。

編輯:從您的錯誤看來,您應該將項目定義為DLL,因為您嘗試創建可執行文件,因此它會尋找main方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM