[英]In visual studio '13 how do I make it so I can include dll files in a relative sub folder of my exe?
在C#中,我知道有一种方法可以编辑汇编配置文件或类似的文件,但是对于C ++,我不知道如何创建它,而不是将我的所有dll放在根目录中,例如/ libs或/ bin /文件夹,我的exe将在其中查找dll文件?
Your EXE doesn't look for DLL files. 您的EXE不会寻找DLL文件。 That means it doesn't matter whether you're using C++ or C#.
这意味着无论您使用的是C ++还是C#。 Visual Studio is even less relevant as it's not even present when your EXE runs.
Visual Studio的相关性甚至更低,因为在EXE运行时甚至不存在。
Windows looks for DLLs. Windows查找DLL。 In your C# example, Windows uses the assembly manifest to guide the search.
在您的C#示例中,Windows使用程序集清单来指导搜索。 In your C++ example, you didn't add one, so Windows uses just the default paths.
在您的C ++示例中,您没有添加一个,因此Windows仅使用默认路径。 The solution is thus obvious: use a similar manifest.
因此,解决方案显而易见:使用类似的清单。
If you're loading the DLL at runtime you can simply write hDll = LoadLibrary("subFolder\\\\test.dll");
如果在运行时加载DLL,则只需编写
hDll = LoadLibrary("subFolder\\\\test.dll");
. 。 At first Windows looks for the DLL in the directory your program is located.
首先,Windows在程序所在的目录中查找DLL。 Therefore
test.dll
will be found in app_dir/subFolder/test.dll
(app_dir = path of executable). 因此
test.dll
将中找到app_dir/subFolder/test.dll
(APP_DIR =可执行的路径)。 Note that this also works if the current directory is different to app_dir
. 请注意,如果当前目录不同于
app_dir
,则这也适用。
Look at MSDN for more information about DLL searching . 有关DLL搜索的更多信息 ,请参见MSDN。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.