开发者

Missing msvcr100.dll error while running an executable built with MinGW

I am successfully compiling (with MinGW) and running my C++ program (which calls Java classes through JNI) consisting of multiple files on my Win7-64bit system. Compiling and running is done by 2 batch files. I installed Visual Studio C++ 2010 some time ago but haven't used it since.

I am now trying to deploy this program to another computer running WinXP-32bit and I am facing a "missing msvcr100.dll" error. I installed the latest MinGW and JDK, I compiled my program using the same batch file, but when I'm running it, I get the error. Visual Studio is not used in any part of the building (and I don't want it to), so I find it strange that I get this message about an MSVC++ dll.

compile.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%开发者_StackOverflowJDK_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

run.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

Is it possible that one of my external includes is causing this? Here they are:

#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <jni.h>
#include <vector>
#include <string.h>
#include <fstream>
using namespace std;

I would appreciate any help to overcome this error.

K


While MinGW is a distribution of GCC, to allow it to run natively on Windows without having a Linux emulation layer like Cygwin it does not use the GNU C library. Instead it uses Microsoft's C Runtime. I have not used MinGW for a while, when it used MSVCRT.DLL from VC++ 6.0, which was more or less ubiquitous in Windows installations at the time as it shipped with installations since late Win95 editions.

It is quite possible that your installation of Windows does not have the later runtime if it was not distributed with it and you have not installed any application with which it was distributed. It may be that you have only the 64 bit DLL and need to install the 32 bit DLL.

The simple solution is to install Microsoft's VC++ re-distributable package(s).

Microsoft Visual C++ 2010 Redistributable Package (x64)

Microsoft Visual C++ 2010 Redistributable Package (x86)


Added Note: According to both http://mingw-w64.sourceforge.net/ and http://www.mingw.org, MinGW still depends on MSVCRT.DLL, so I wonder what you have done or where you obtained your distribution that makes it depend on MSVCRT100.DLL? Some experimental build perhaps?


The DLL contains the runtime for compiled programs. It must be installed on the other machine to be able to run the program.

Standard program distributions have an install package that does this for you, or you can install it manually.

See here for download instructions

http://www.microsoft.com/download/en/details.aspx?id=5555


MinGW merely emulates Linux OS calls. Let me explain..

When you ceate a binary that runs on a certain OS, that binary needs to know how to interact with the underlying OS. This is important for things like memory allocation. The binary doesn't natively "know" how to allocate RAM, instead, it asks the host OS to give it some RAM. It does this, by calling an allocation function that resides at a predetermined "address" inside the OS.

How does the application know what "address" the allocation method exists at?

When you compile the binary, you bind to it a "C runtime library (CRT)". This library contains all the mappings for OS interactions that the binary will need. So for example, when you link the CRT, the binary now knows where it can find the memory allocation function that is exposed by the OS.

MinGW, inserts an emulation layer such that an application thinks its linking to a Linux CRT, but really, the emulation layer just redirects calls to the Microsoft CRT.

Windows, has a number of different CRTs available. On all distributions, you can find somewhere in %PATH%, the file msvcrt.dll. This file, provides all support that a binary would need to run in the OS.

When you install Visual Studio, you get updated versions of the CRT:

  1. In VS 2005: msvcrt80.dll
  2. In VS 2008: msvcrt90.dll
  3. In VC 2010: msvcrt100.dll

Apparently, by installing Visual Studio, you've caused MinGW's emulation layer to link against msvcrt100.dll, rather than the msvcrt.dll, that comes distributed on all windows machines. I don't know why this is happening, but this IS what is happening.

EDIT

The command:

dlltool --input-def .\lib\jvm.def --kill-at --dllname jvm.dll --output-lib .\lib\libjvm.dll.a

Which is producing a file that links in jvm.dll might creating the msvcrt100.dll dependency. That is, jvm.dll might be dynamically linked against the newest CRT, and because you require jvm.dll you indirectly need msvcrt100.dll.

Are there any dll's found in ""C:\Program Files\Java\jdk1.7.0\bin"?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜