帮助将大型项目重新设计为DLL模块. [英] Help on re-engineering a big project into DLL modules.

查看:84
本文介绍了帮助将大型项目重新设计为DLL模块.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,
我们有80个.cpp文件的项目,在构建和维护时,它们是如此之大而又难以执行,因此我们希望将代码分解为小的小型DLL模块.

Hey,
We have project of 80 .cpp files which so big and hard to conduct while building and maintaining so we want to break the code into small small DLL modules. Can any body help me on DLL implementation?

推荐答案

欢迎使用CP.

我们通常不会为您做任何工作,尤其是当您的描述含糊不清时,但我会照做的.

如果您希望它成为模块化类型的系统,那么您的工作就很容易完成.您必须为应用程序提供某种外部接口,每个模块都可以与之交互以实现其结果.
例如,对于一个IDE(Visual Studio),每个DLL中可能都有一个调用的函数,询问它是否知道如何格式化该语言,如果知道,则要求其格式化纯文本以返回格式化的文本.最终需要做很多工作.

如果您只希望将DLL作为将代码分解为更有意义的项目的一种方式,那么它就很简单(甚至可以在同一端使用静态库).
基本上,创建一个新的MFC DLL项目并将所需的源文件和头文件移到新项目中.
您将需要某种方法来导出所有功能(.def文件或__declspec(dllexport)).
然后,您只需像往常一样#include类头文件(尽管.h现在位于其他文件夹中),并链接到为项目生成的.lib文件.
Welcome to CP.

We generally don''t do your work for you, especially when your description is so vague, but I will have a shot.

If you want it to be a modular type system, then you have your work cut out for you. You will have to have some sort of external interface to your application that each module can interact with to achieve its result.
For a IDE for example (Visual Studio), there may be a function called in each DLL asking it if it knows how to format this language, and if it does, then ask it to format the plain text to return the formatted text. This ends up been quite a lot of work.

If you just want the DLLs as a way of breaking your code up into more meaningful projects then it is rather simple (and you could even use static libraries to the same end).
Basically, create a new MFC DLL project and move the source and header files you want in it to the new project.
You will need some method of exporting all the functions (either a .def file or a __declspec(dllexport)).
Then you just #include the class header file as usual (although the .h is in a different folder now) and link against the .lib file generated for the project.


santoshmaruti写道:
santoshmaruti wrote:

任何机构都可以在DLL实现上为我提供帮助吗?

Can any body help me on DLL implementation?



该文档始终为您提供帮助:动态链接库" [在MSDN上 ^ ] .
:)



The documentation helps you all the time: "Dynamic-Link Libraries"[^] at MSDN.
:)


然后要么用__declspec(dllexport)导出函数IsNumeric(),要么不链接定义在其中的库.

对于静态链接到DLL(这是您正在做的事情),链接器需要能够获得代码的(编译版本),以将其包括在最终的.exe中.

您可以使用#pragma comment(lib, "mydll.lib")指示链接器在库中查找代码,或者将其添加到项目属性的链接器"选项中的其他相关性"中.
在输出目录中,将在您的.dll文件旁边生成一个.lib文件.
您将需要为要创建的每个要静态加载的DLL执行此操作.
Then either you havnt exported the function IsNumeric() with __declspec(dllexport), or you aren''t linking against the library that it is defined in.

For static linking to DLLs (which is what you are doing) the linker needs to be able to get the (compiled version) of the code to include it in the final .exe.

You can instruct the linker to look for code in libraries with either #pragma comment(lib, "mydll.lib") or adding it to the Additional Dependancies in the Linker options for the project properties.

There will be a .lib file generated alongside your .dll file in the output directory.
You will need to do this for every DLL that you create that is to be loaded statically.


这篇关于帮助将大型项目重新设计为DLL模块.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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