【博客搬家】如何查询到程序运行所依赖的库文件【亲历】***

前段时间工作编写的程序运行一切正常,但是在重装系统后,运行程序出现错误:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: D:/eclipse/workspace/run/zhupin.dll: Can't find dependent libraries
查阅资料知道,是因为以前开发时由于涉及本地调用安装了VC,但是现在并没有装VC,所以依赖于VC所拥有的库文件的程序无法正常运行。可以装VC,但是如何知道该程序到底依赖于哪几个库文件呢。查阅资料,看到这样一篇文章:地址 http://the-double-0-project.net/blog/?p=126
原文:
================= ================== ================== ================== ===
Installing PHP 5.2.5 on Windows XP for Tomcat 6.0.13 - Issues resolved Posted by: project_00 in PHP, Perl, Others , Software, Web Apps I was playing around with the idea of doing a small personal PHP project, and I decided to do a fresh install of the latest version of PHP, which is 5.2.5. Since I’m already using the Apache Tomcat 6.0.13 server, I decided to run PHP on that instead of setting up the Apache HTTP server. I’ve done something similar before , so I didn’t think it would be much of a problem. However, it is a bit more tricky than expected.
Windows PHP installer is broken
Initially, I used the Windows installer. The PHP install directory used was “C:/Program Files/PHP”. Installing was a breeze and I could even use the php5srvlt.jar and put it into the WEBINF/lib directory without doing anything. The reflect.properties and servlet.properties files already have the line
library=php5servlet
instead of
library=phpsrvlt
So I followed the steps outlined. When I tried to access the test page, I got this.
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet php threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
…..(edited for brevity)
root cause
java.lang.UnsatisfiedLinkError: C:/Program Files/PHP/php5servlet.dll: Can’t find dependent libraries
java.lang.ClassLoader$NativeLibrary.load(Native Method)
…..(edited for brevity)
I checked the install directory and php5servlet.dll was there. What are the dependent libraries? After reading some of comments on Angusman’s site and some discussions on Java forums, it turns out that the problem is due to missing DLLs. I downloaded a tool called Dependency Walker . It is very useful, I loaded php5servlet.dll and got the following.

So php5ts.dll is missing. Searched for the file on PECL4WIN but could not find it. So I downloaded the zipped PHP files, then I noticed that there is an error in the original installer for PHP 5.2.5. Apparently the updated installer still has issue.
Steps I took to get it working
Uninstall the initial install and remove all the files in the install directory Unzip the downloaded PHP zipped file into the install directory. Download php5servlet.dll from PECL4WIN and put it in the install directory. If you don’t have it you will get an error message like:
exception
javax.servlet.ServletException: Servlet.init() for servlet php threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
…..(edited for brevity)
root cause
java.lang.UnsatisfiedLinkError: no php5servlet in java.library.path
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
…..(edited for brevity)
Edit the following paths in the php.ini file: include_path = “C:/Program Files/PHP/PEAR”, doc_root = “C:/Program Files/Apache Software Foundation/apache-tomcat-6.0.13/webapps”, extension_dir = “C:/Program Files/PHP/ext” Uncomment a few extensions in php.ini and ensure the DLLs are in the extension directory, eg curl or bz2 Save the php.ini file. If you right-click and php.exe, php-cgi.exe and php-win.exe and see the properties, you will see this message “Security: This file came from another computer and might be blocked to help protect this computer.” I chose to unblock, but I’m not sure if there’s any issue leaving it on.
Create web.xml, php5srvlt.jar and test page like what Angusman says in the appropriate directory in the webserver. If php5srvlt.jar is not in the correct directory you’ll get an error message like this:
exception
javax.servlet.ServletException: Wrapper cannot find servlet class net.php.servlet or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
…..(edited for brevity)
root cause
java.lang.ClassNotFoundException: net.php.servlet
…..(edited for brevity)
I already have them so I skipped this.
Create the following environment variables PHP_HOME=”C:/Program Files/PHP”, PHP_HOME_EXT=”%PHP_HOME%/ext”, PHPRC=”%PHP_HOME%”. PHPRC is used to determine the location of the php.ini file but it is not the only place where it can be set. The locations being searched for the php.ini file follows a certain order. For my purpose this setting PHPRC is sufficient. If this is not set, the default location will be used, and may result in php.ini not being loaded, which in turn results in the configuration settings being set to some unexpected values, modules not being loaded as seen in phpinfo(), etc. Some examples. Wrong include path

Wrong extension directory

Append the environment variables to the PATH environment variable. Reboot so that the PATH changes are set. If not, you’ll get some error like this where the environment variable appears correctly on it’s own but not in the PATH.
================ ================== ================== ================== ====

在看到这篇文章后知道有一个叫dependencywalker的软件,官方地址是: http://www.dependencywalker.com/

目前最新版本下载地址是: http://www.dependencywalker.com/depends22_x86.zip
下下来以后运行 FILE---OPEN--->将出错信息里的 D:/eclipse/workspace/run/zhupin.dll 文件打开,此时软件分析该文件,出来一个警告,点确定,看到如下界面:



这就说明该文件运行所依赖的库文件丢失,上面说明的是 MFC42D.DLL   MSVCRTD.DLL  MSJAVA.DLL 文件缺失,如果不想安装VC 可以把这几个文件拷到系统 SYSTEM32 文件夹里。


以上几个库文件说明:


mfc42d.dll 信息:
软件简介:
mfc42d - mfc42d.dll - DLL文件信息
DLL 文件: mfc42d 或者 mfc42d.dll
DLL 名称: MFCDLL Shared Library - Debug Version
  
描述:
mfc42d.dll是MFCDLL共享库文件,用于支持调试版本的MFC程序。

属于: MFC
系统 DLL文件: 否
常见错误: File Not Found, Missing File, Exception Errors
下载地址:
http://www.xdowns.com/soft/xdowns.asp?softid=39954&downid=53&id=42429
http://www.xdowns.com/soft/xdowns.asp?softid=39954&downid=49&id=42429

MSVCRTD.DLL 信息
msvcrtd - msvcrtd.dll 下载- DLL文件信息
DLL 文件: msvcrtd 或者 msvcrtd.dll
DLL 名称: Microsoft (R) C Runtime Library
描述:
msvcrtd.dll是微软编译程序调试版本相关文件

下载地址:
http://www.xdowns.com/soft/184/dll/2007/Soft_39811.html

MSJAVA.DLL
下载地址:
http://www.xdowns.com/soft/softdown.asp?softid=39809
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值