推荐读者, 我们使用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 [ ^ ],无论如何,它对于明确DLL加载(即通过LoadLibrary). 您可能对动态链接库搜索顺序 [ ^ ]和动态链接库重定向 [ ^ ]. :)
一个简单的解决方案是将您的dll目录添加到系统路径. 1.您指出dll的数量已增加.我知道这不是很大的.也许您创建了一堆,而不是更多. 2.请不要将您的dll安装到系统文件中.那不是解决方案,您会遇到问题. 3.我不明白将dll放入.exe文件的问题是什么.它不仅简化了安装过程,而且还可以防止您头疼. 4.最后,如果要安装然后在单独的文件夹中,我想问自己一个问题,如果将其放在系统目录中,为什么会起作用.简单的答案是因为它在搜索路径中.当您的dll需要加载时,加载器会在放弃之前寻找很多地方. 因此,简短的答案是您需要将dll所在的文件夹添加到系统路径中. 打开命令窗口,然后键入path.你看到了什么?那是你的秘密成分.您的安装需要将完整路径附加到PATH
Respected reader, We developed a project using the MFC Appwizard. A project contains 80 .cpp files and .h files. The Project was so big and hard to maintain and also build. So according to the suggestion of Andrew Brok (author of code project) we break up whole project into small .dll project. We used technique of static __declspec(dllexport). Now the project is sorted into small .dll projects but the number of .dll files has increased. So while creating the setup, all the .dll files must be present in the current .exe folder project or sytsem32/ folder. If we want all dll in separate folder /dll. It''s not working. While the application running has an error that says "-----.dll not fount please reinstall application." 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
解决方案 santoshmaruti wrote: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实施
发布评论