【发布时间】:2014-09-06 19:06:17
【问题描述】:
我正在尝试将自定义 c++ dll (使用 jni) 加载到 java,但我有一个 问题: 我的 dll 使用 cryptopp 库,当 java 尝试加载取决于(包括cryptopp),应用程序退出并显示以下消息:
Java 结果: -1073741571
那是什么,我可以在不删除cryptopp的情况下解决这个问题吗?
更新:
如果我评论了文件 zCypto.h 和 zCypro.cpp,并删除了 cryptopp 库的所有使用,它可以正常工作,如果我加载 cryptopp,则会引发错误。 Java 代码:
public static void main(String[] args){
System.loadLibrary("cryptopp");
System.loadLibrary("ZCPP_Code64");
}
CPP 源(我在 Visual Studio 2012 中制作 dll):
#include "zCrypto.h"
JNIEXPORT void JNICALL Java_ru_zontwelg_Loader_loadCache
(JNIEnv *env, jobject jobj)
{
std::fstream stream;
stream.open("C:\\testing_capturing\\enc.zwac", ios_base::binary | ios_base::in);
// Other decode & read stuff here ...
stream.close();
}
标题:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class ru_zontwelg_Loader */
#ifndef _Included_ru_zontwelg_Loader
#define _Included_ru_zontwelg_Loader
extern "C" {
/*
* Class: ru_zontwelg_Loader
* Method: loadCache
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_ru_zontwelg_Loader_loadCache
(JNIEnv *, jobject);
}
#endif
zCrypto.h:
#ifndef ZontWelg_zCrypto
#define ZontWelg_zCrypto
#include <dll.h>
#include <cstdio>
#include <Windows.h>
#include <iostream>
#include "cryptlib.h"
using CryptoPP::Exception;
#include "hex.h"
using CryptoPP::HexEncoder;
using CryptoPP::HexDecoder;
#include "base64.h"
using CryptoPP::Base64Encoder;
using CryptoPP::Base64Decoder;
#include "filters.h"
using CryptoPP::StringSink;
using CryptoPP::StringSource;
using CryptoPP::StreamTransformationFilter;
#include "sha.h"
#include "rsa.h"
#include "hex.h"
#include "osrng.h"
#include "secblock.h"
#include "modes.h"
#include "aes.h"
using CryptoPP::AES;
//#include "ccm.h"
using CryptoPP::CBC_Mode;
#pragma comment(lib, "cryptlib.lib")
//#pragma comment(lib, "crypt32.lib")
#pragma comment(lib, "cryptopp.lib")
using namespace std;
class zCrypto {
public:
static string base64(string in);
static string from_base64(string in);
static string decrypt(const std::string& str_in);
};
#endif
【问题讨论】:
-
如果没有看到您的代码,很难判断您做错了什么。你能试着制作一个出现这个问题的最小的程序,然后把它粘贴到这里吗?
-
Eclipse: Java was started but returned exit code -1073741571 的可能重复项。这可能很难搜索,因为 Google 将减号解释为“从结果中删除 1073741571”。试试这个搜索:Java "-1073741571".
-
@Draiget - 我们需要更多细节。这是一个 Android/Ecplise 项目吗?这是一个 Windows 项目吗(可能来自潜在的重复项目)。虚拟机有多少内存?您是否使用
javah从您的 Java 类文件中生成 C/C++ 标头?你是专门调用你的DLL吗?还是您偶尔调用 Crypto++ DLL? -
@jww - 我尝试在没有“-”的情况下搜索错误,但找不到任何与我的问题相关的内容。这是 NetBeans 中的 Java Application 项目(在 Windows 下编写),dll 是 c++ 动态库(在 Visual Studio 2012 中编写)。对于生成标题我使用
javah
标签: java java-native-interface native-code crypto++