如何更改应用程序使用的 .dll 搜索路径? [英] How can I change the .dll search path my application uses?

查看:85
本文介绍了如何更改应用程序使用的 .dll 搜索路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

随着我的应用程序的增长,我发现自己使用的第三方库越来越多,而我的应用程序目录中 .dll 的数量也在增长(在撰写本文时为 11).这本身并不是一个问题,但它很丑陋.我更愿意将它们放在bin/"或其他东西中.

As my application grows, I find myself using more and more third-party libraries, and the number of .dll's in my application directory is growing (11 at the time of this writing). This isn't really a problem, per se, but it is ugly. I would much rather be able to put these in "bin/" or something.

这能做到吗,还是我在浪费时间在一些无关紧要的事情上?

Can this be done, or am I wasting my time on something that's not really an issue?

唯一的真正优势是,我可以将 x86 和 x64 版本的 exe 放在同一目录中,并让它们从相应的 dll 文件夹(bin32/bin64/,例如).

The only real advantage this would give me would that I could put the x86 and x64 versions of the exe in the same directory, and have them load from the appropriate folder of dll's (bin32/ or bin64/, for instance).

我使用的是 C++ 和 MinGW-W64.

I'm using C++ and MinGW-W64.

推荐答案

您可以使用 GNU 链接器的 -rpath 标志.

You can use the GNU linker's -rpath flag.

例如,这将在本地目录中搜索依赖的 dll:-Wl,-rpath,./

For example, this will search the local directory for dependent dlls: -Wl,-rpath,./

特别是在您的情况下,您需要:-Wl,-rpath,./bin

So specifically in your case you'd want: -Wl,-rpath,./bin

这篇关于如何更改应用程序使用的 .dll 搜索路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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