关于大型项目中的DLL实施 [英] About Dll implementation in big project

查看:126
本文介绍了关于大型项目中的DLL实施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

推荐读者,

我们使用MFC Appwizard开发了一个项目.一个项目包含80个.cpp文件和.h文件.
该项目是如此之大,难以维护和构建.
因此,根据代码项目的作者Andrew Brok的建议,我们将整个项目分解为小的.dll项目.我们使用了静态__declspec(dllexport)的技术.


现在,该项目被分类为小的.dll项目,但是.dll文件的数量已经增加.因此,在创建安装程序时,所有.dll文件都必须存在于当前的.exe文件夹项目或sytsem32/文件夹中.

如果我们要将所有dll放在单独的文件夹/dll中.

它不起作用.正在运行的应用程序出现错误,提示"-----.dll找不到,请重新安装应用程序."

我也尝试过SelDllDirectory()函数,但是它给出了一个错误:未找到函数.然后,我包含了给定功能的文件window.h,它在Windows 2003服务器上给出了错误.


请帮助我们从项目中分离dll文件.

解决方案

santoshmaruti写道:

我也尝试了SelDllDirectory()函数,但它给出了一个错误:函数未找到.


该函数的名称为 SetDllDirectory [动态链接库搜索顺序 [ ^ ]和动态链接库重定向 [
I have also tried SelDllDirectory() function but its gives an error: function not found. Then I included the file window.h for the given function and it gives an error on Windows 2003 server.


Please help us for separation of dll files from project

I have also tried SelDllDirectory() function but its gives an error: function not found.


The function''s name is
SetDllDirectory[^], anyway it is helpful just for explicit DLL loading (i.e. via LoadLibrary).

You might be interested in Dynamic-Link Library Search Order[^] and in Dynamic-Link Library Redirection[^].
:)


A simple solution is to just add your dll directory to the system path.


Ok there are a number of issues with your approch.

1. You stated that the number of dlls have increased. I have it is not by magnitude. Maybe you have created a bunch of them, not more.
2. Please don''t install your dlls into System files. That is not the solution and you will run into a problem.
3. I don''t understand what is the issue placing your dlls with your .exe file. Not only it simplifies your install it will prevent you from headaches down the line.
4. Finally, if you want to install then in separate folder, I want you to ask yourself why does it work if your put it in the system directory. The simple answer is because it is in the search path. When your dll needs to be loaded there are a number of places the loader looks before it gives up.

So, the short answer is you need to add the folder in which your dll resides into the system path.

Open command window and type path. what do you see? that is your secret ingredient. Your install needs to append the full path into the PATH


这篇关于关于大型项目中的DLL实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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