设置Win32控制台应用程序的库路径 [英] Setting Library path for win32 console applications

查看:476
本文介绍了设置Win32控制台应用程序的库路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试执行一个简单的HelloWorldwin32控制台应用程序时,我收到找不到dll:重新启动应用程序可能会解决问题错误。
我知道.dll的位置。
如何在命令提示符下执行.exe时指定其位置?



PS:将.dll复制到.exe的当前目录似乎可以解决问题,但是这种方法在这种情况下是不合适的。

解决方案

DLL加载发生在windows的管道中。

如果没有在与应用程序相同的目录中找到DLL,则会自动扫描PATH以查找目录。



所以,最简单的答案是将包含该DLL的目录添加到PATH中。根据您的代码何时需要加载DLL,您可能(临时)修改HelloWorld应用程序中的PATH。


I am getting "dll not found:restarting the application may fix the problem" error when i try to execute a simple "HelloWorld" win32 console application. I know the location of the .dll. How to specify its location when executing the .exe from command prompt?

PS: copying the .dll to the .exe's current dir seems to solve the problem, but this approach is not suitable in this case.

解决方案

DLL loading happens deep in the plumbing of windows.

If the DLL is not found in the same directory as the application, the PATH is automatically scanned in order to find the directory.

So, the simplest answer to your problem is to add the directory containing the DLL to your PATH. Depending on when the DLL needs to be loaded by your code, you may be able to (temporarily) modify the PATH from inside your "HelloWorld" application.

这篇关于设置Win32控制台应用程序的库路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆