有没有办法为应用程序制作模块而不是.dll或.so文件? [英] Is there a way to make a module for an app without it being a .dll or .so file?

查看:76
本文介绍了有没有办法为应用程序制作模块而不是.dll或.so文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道(除了使用PHP;)C ++中的哪些内容可以提供与PHP相似的功能include();


在PHP中你几乎可以在任何地方输入include()并且该文件将动态包含。这很好,因为你可以检查它是否需要逐个文件包含,这很好,因为它可以保持紧凑。


现在唯一类似的解决方案我在C ++中看到的是#include指令,但无论如何都包含文件,即使它不需要。


我想制作模块化应用程序,但是我不喜欢我不想做过度编译来开发上述模块。我的目标是开发环境,然后单独开发模块并在完成后将它们放在模块文件夹中。


有没有通用的方法可以在不进入动态链接库的情况下执行此操作.so文件?


谢谢。

I was wondering (besided using PHP ;) what in C++ could provide similar functionality to PHP''s include();

In PHP you canjust type include() almost anywhere and that file will be included dynamically. It''s nice because you can check if it needs to be included on a file by file basis, which is nice because it keeps things compact.

Right now the only similar solution I see in C++ is the #include directive, however that includes the file no matter what, even if it''s not needed.

I want to make a modular application, however I don''t want to have to do excessive compiling to develop the said module. My goal is to develop the environment, then develop the modules seperately and toss them in a module folder when done.

Is there a generic way to do this without going into Dynamic Link Libraries or .so files?

Thanks.

推荐答案

PHP和C ++的功能不同。他们有不同的编译代码的方法。两者都有一些名为include的东西,但它们非常不同。 PHP包括汇总代码。预处理器也是如此,但是你没有使用include来汇总源文件。

PHP and C++ function differently. They have different approach to compiling code. Both share something called include, but they are very different. PHP?s include puts together code. So does the preprocessor include, but you don?t use the include to put together source files.


#include指令,但是包括文件no什么,即使它不需要。
#include directive, however that includes the file no matter what, even if it?s not needed.



因此使用标题保护来防止多次包含。

Hence the use of header guards to prevent multiple inclusion.


我想要制作模块化应用程序,但是我不想过度编译来开发所述模块。
I want to make a modular application, however I don?t want to have to do excessive compiling to develop the said module.



单词?module?并不代表任何具体的东西。你应该准确描述你为你的程序设想的内容。


?开发环境?什么都没有意义。 ?开发模块?也没意思。我们需要您的具体信息。

The word ?module? doesn?t mean anything specific. You should describe exactly what you envision for your program.

?Develop the environment? doesn?t mean anything. ?develop the modules? doesn?t mean anything either. We need specifics from you.


我想这可能有点模糊,抱歉。


对于环境我的意思是我想要一个主控制器设置所有环境变量和权限,然后处理正在进行的实际请求(也许它正在写一个文件)。当环境启动时,我希望它扫描一个模块列表,如果模块已启用,我希望它被加载,否则,我不希望它(模块)占用内存。


对于一个模块,我的意思是一个预先编译的二进制文件,我(或任何人)可以只是扔进一个文件夹并开始使用它的功能(如果它被启用)。 />

我想你可以用Firefox来思考它。浏览器为模块设置了所有内容,模块扩展了功能。


我只是想知道是否有办法在不使用.dll或.so文件的情况下完成此操作。
I guess that may have been a bit vague, sorry.

For an environment I mean that I want one main controller to set up all environment variables and permissions, then handle the actual request being made (maybe it''s writing a file). When the environment starts up I want it to scan a list of modules, and if the module is enabled, I want it to be loaded, otherwise, I don''t want it (the module) taking up memory.

For a module, I mean a pre-compiled binary file that I (or anyone) can just toss in a folder and begin to use it''s functionality (should it be enabled).

I suppose you can think it in terms of Firefox. The browser setups everything for the module, and the module extends the functionality.

I''m just wondering if there''s a way to acomplish this without using .dll or .so files.



我只是想知道是否有一种方法可以在不使用.dll或.so文件的情况下完成此操作。
I?m just wondering if there?s a way to acomplish this without using .dll or .so files.



当然,您可以压缩模块,将模块扩展名重命名为其他内容,然后将其放入文件夹中。看看Firefox的模块格式。 xpi是一个zip文件。


我不知道为什么你反对dll文件。该模块必须是某种文件。如果事实证明您需要一个本机二进制文件,那不是一个可执行文件本身,那么dll可能是您的最佳选择。或许它是一个更复杂的文件格式,比如xpi扩展,可以在其中压缩一个dll。


如果你有一个用C或C ++制作的二进制文件,它编译为可执行文件或库。我认为这是你想要的,模块编写者用C创建模块。然后你必须有一个DLL作为结果。考虑压缩或重命名文件扩展名的想法(甚至删除扩展名)。

Sure, you could zip up the module, rename the module extension to something else, and then put that in the folder. Look at Firefox?s module format. The xpi is a zip file.

I?m not sure why you are objecting to dll files. The module has to be some kind of file. If it turns out that you need a native binary file, that isn?t an executable itself, then a dll may be your best option. Or maybe it?s a more complex file format, like the xpi extension, that can have a dll zipped inside of it.

If you have a binary that is made in C or C++, it compiles to either an executable or a library. I presume this is what you intend, the module writers create the module with C. Then you must have a DLL as a result. Consider the idea of zipping or renaming the file extension (or even, dropping the extension).


这篇关于有没有办法为应用程序制作模块而不是.dll或.so文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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