【发布时间】:2011-08-24 16:11:57
【问题描述】:
我正在成功编译(使用 MinGW)并在我的 Win7-64 位系统上运行由多个文件组成的 C++ 程序(通过 JNI 调用 Java 类)。编译和运行由 2 个批处理文件完成。我前段时间安装了 Visual Studio C++ 2010,但从那以后就没有使用过。
我现在正尝试将此程序部署到另一台运行 WinXP-32bit 的计算机上,但我遇到了“缺少 msvcr100.dll”错误。我安装了最新的 MinGW 和 JDK,我使用相同的批处理文件编译了我的程序,但是当我运行它时,我得到了错误。建筑物的任何部分都没有使用 Visual Studio(我不希望它使用它),所以我觉得奇怪的是我收到这条关于 MSVC++ dll 的消息。
编译.bat
rem Set the include paths for the JNI header files("include" and "include\win32" inside the jdk (32-bit) directory).
set JDK_INCLUDE="C:\Program Files\Java\jdk1.7.0\include"
set JDK_INCLUDE_WIN32="C:\Program Files\Java\jdk1.7.0\include\win32"
set PATH=%PATH%;C:\MinGW\bin
rem Build an import library for the jvm.dll from the .\lib\jvm.def file (see http://www.inonit.com/cygwin/jni/invocationApi/archive.html)
dlltool --input-def .\lib\jvm.def --kill-at --dllname jvm.dll --output-lib .\lib\libjvm.dll.a
rem Set the import library directory.
set JVM_IMPORT_DLL=".\lib"
rem Compile all files (including the IngToolTest.cpp) and create an executable file .\bin\COFORM_JNI.exe
g++ -I%JDK_INCLUDE% -I%JDK_INCLUDE_WIN32% .\src\DataTypes\file1.cpp .\src\IngestionTool\file2.cpp ... .\src\file25.cpp Test.cpp -L%JVM_IMPORT_DLL% -ljvm -o .\bin\executable.exe
pause
运行.bat
Rem Set the environment parameter to the path where the properties file resides.
set CONFIG_DIR=..
Rem Set the environment parameter to the actual IP of your VM machine.
set VM_URL=139.191.173.43
Rem Set the location of the jvm.dll (32-bit)
set PATH=%PATH%;C:\Program Files\Java\jdk1.7.0\jre\bin\client
move *.rdf RDFS
.\bin\executable.exe
pause
是否有可能是我的外部包含之一导致了这种情况?他们在这里:
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <jni.h>
#include <vector>
#include <string.h>
#include <fstream>
using namespace std;
如果能帮助我克服这个错误,我将不胜感激。
K
【问题讨论】:
标签: c++ java-native-interface mingw