Java-JNI无法在NetBeans上检测到__int64
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Java-JNI无法在NetBeans上检测到__int64,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2008字,纯文字阅读大概需要3分钟。
内容图文
我正在尝试编译本机库以从Java(与JNI)一起使用它.我遵循了本教程:
https://cnd.netbeans.org/docs/jni/beginning-jni-win.html
错误
当我尝试编译时,出现此错误(请参见第4行):
[...]
In file included from ../../Progra~2/Java/jdk1.8.0_91/include/jni.h:45:0,
from HelloWorldNative.h:3,
from HelloWorldNative.c:6:
../../Progra~2/Java/jdk1.8.0_91/include/win32/jni_md.h:34:9: error: unknown type name '__int64'
typedef __int64 jlong;
^
nbproject/Makefile-Debug.mk:66: recipe for target 'build/Debug/Cygwin-Windows/HelloWorldNative.o' failed
[...]
我可以解决此错误,方法是在#include< jni.h>之前添加typedef long long __int64.但我认为我做错了什么.
编码
这是代码:
头文件:
/* DO NOT EDIT THIS FILE - it is machine generated */
typedef long long __int64; // <============ Why do I need to do this?
#include <jni.h>
/* Header for class helloworld_Main */
#ifndef _Included_helloworld_Main
#define _Included_helloworld_Main
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: helloworld_Main
* Method: nativePrint
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_helloworld_Main_nativePrint
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
源文件:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
#include "HelloWorldNative.h"
JNIEXPORT void JNICALL Java_helloworld_Main_nativePrint
(JNIEnv *env, jobject _this){
}
解决方法:
__int64是Visual Studio specific type
使用标准类型,例如int64_t or uint64_t.在< cstdint>中定义C和< stdint.h>中的对于C.
您可以在JNI常见问题解答中找到针对您的错误的确切解决方案:
http://www.oracle.com/technetwork/java/jni-j2sdk-faq-141732.html
Your compiler might not like __int64 in jni_md.h. You should fix this by adding:
#ifdef FOOBAR_COMPILER
#define __int64 signed_64_bit_type
#endif
where signed_64_bit_type is the name of the signed 64 bit type supported by your compiler.
所以你应该使用:
#define __int64 long long
要么:
#include <stdint.h>
#define __int64 int64_t
这与您最初所做的非常相似
内容总结
以上是互联网集市为您收集整理的Java-JNI无法在NetBeans上检测到__int64全部内容,希望文章能够帮你解决Java-JNI无法在NetBeans上检测到__int64所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。