链接到环境变量中的DLL [英] Linking to a DLL in an environment variable

查看:127
本文介绍了链接到环境变量中的DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何链接到存储在运行时目录以外的地方的DLL。目录的位置如下

I would like to know how to link to a DLL stored in a place other than the runtime directory. The location of the directory is as follows

%LWE_HOME%/lib/engine.dll

如何告诉程序在那里寻找它而不是在运行时目录中?



我正在寻找一个跨平台的解决方案。如果没有一刀切的解决方案,请为我提供* n * x操作系统和windows的解决方案。

How do I tell the program to look for it there instead of in the runtime directory?

I am looking for a cross-platform solution. If there isn't a "one size fits all" solution, please provide me with solutions for both *n*x operating systems and windows.

推荐答案

所有的东西SA说是正确的。这就是为什么我们有这个:

http:// msdn.microsoft.com/en-us/library/ms682586%28VS.85%29.aspx [ ^ ]



我认为最好的解决方案就是放入dll哪里可以找到。但要达到你想要的目的。你可以通过注册表来做到这一点:

http://www.codeguru.com/cpp/wp/dll/article.php/c99/Application-Specific-Paths-for-DLL-Loading.htm [ ^ ]
All of what SA has said is correct. That's why we have this:
http://msdn.microsoft.com/en-us/library/ms682586%28VS.85%29.aspx[^]

I think the best solution is put the dll where it can be found. However to achieve what you wish look at this. You can do it via registry:
http://www.codeguru.com/cpp/w-p/dll/article.php/c99/Application-Specific-Paths-for-DLL-Loading.htm[^]


没有运行时目录这样的概念。没有链接到环境变量中的DLL这样的概念。没有一种预定义的通用方式可以说明在哪里寻找DLL(我在谈论本机DLL; .NET程序集可以放在定义良好的程序集缓存中。)



这就是我们所谓的 DLL地狱的原因之一:

http://en.wikipedia.org/wiki/DLL_hell [ ^ ]。



有些人说,Linux 发行版对重用组件及其注册有严格的规定所有安装的方式可以找出安装和不安装的内容,但不是Windows。



现在,环境变量有时用于此目的,但这种方式纯粹是依赖于应用程序。原则上,您可以为共享某些DLL的应用程序组开发自己的系统。我认为使用环境变量是一种非常糟糕的方法;它主要由传统软件使用(可能是在典型的计算机系统目前使用的应用程序少得多时创建的)并且只会污染系统。有些背景,请参阅:

http://en.wikipedia.org/wiki/Environment_variable [ ^ ]。



-SA
There is no such concept as "runtime directory". There is no such concept as "linking to a DLL in an environment variable". There is no one predefined universal way of saying where to look for a DLL (I'm talking about native DLLs; .NET assemblies can be put in the well-defined Assembly Cache.)

This is one of the reasons why we have so called "DLL hell":
http://en.wikipedia.org/wiki/DLL_hell[^].

Some, say, Linux distro have strict rules for reusing components and their registration the way all installations can find out what to install and what not, but not Windows.

Now, environment variables are sometimes used for such purpose, but this way is purely application-dependent. In principle, you can develop your own system for the group of applications sharing some DLLs. I think using environment variables is a pretty bad approach; it is mostly used by legacy software (possibly created when typical computer systems had much less applications then these days) and just contaminates the system. For some background, please see:
http://en.wikipedia.org/wiki/Environment_variable[^].

—SA


搜索库没有通用的方法...



在Windows中,您可以使用PATH环境变量。



在Linux或Unix中,您可以使用LD_LIBRARY_PATH环境变量来指定库的路径。如果路径未更改(大多数情况下都是如此),则可以在构建环境中指定LD_RUN_PATH环境变量。或者,您可以使用-runpath链接器选项。
There is no common way to search for libraries...

In Windows you can use the PATH environment variable.

In Linux or Unix you can use LD_LIBRARY_PATH environment variable to specify the library's path. If the path doesn't change (this is true most of the time), you can specify the LD_RUN_PATH environment variable in your build environment. Alternatively, you can use -runpath linker option.


这篇关于链接到环境变量中的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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