473,471 Members | 4,687 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Is there a way to make a module for an app without it being a .dll or .so file?

16 New Member
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.
Jul 27 '08 #1
10 1429
oler1s
671 Recognized Expert Contributor
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 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.
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.
Jul 27 '08 #2
Hero Doug
16 New Member
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.
Jul 27 '08 #3
oler1s
671 Recognized Expert Contributor
I’m just wondering if there’s a way to acomplish this without using .dll or .so files.
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).
Jul 28 '08 #4
Hero Doug
16 New Member
The objection to using .dll or .so files is that they have be linked to the application in order to be able to use them? I'm basing this off the fact thta when you want to install a PHP module you have to recompile PHP with -enable <modulename>

When building this application I obvisouly won't know what other modules developers will make and won't be able to hardcode the inclusion, so it'll have to be dynamic.

I'll probably have it tested by the time you reply, but what about some procedural code in gloabl scope (or better, within the module controller object) that scans a config file and looks in the module folder and then includes the enabled modules (essentially pre-compiled libraries).
Jul 28 '08 #5
Banfa
9,065 Recognized Expert Moderator Expert
The objection to using .dll or .so files is that they have be linked to the application in order to be able to use them?
No they don't, as long as the dll uses a defined interface that the application knows then the dll can be linked at run time calling the WIN32 API function LoadLibrary.
Jul 28 '08 #6
Hero Doug
16 New Member
Alright, I think I'm on the right path now.

I should be able to look at the environment variables to tell what operating system it is, then call the approproiate system API to dynamically link the library into the address space.

I found a resource (here that brings up an interesting point that different compilers and even different compiler versions may not be able to compile compatible libraries becaue their vtable may not match (mentioned on page 2 paragraph 4). Is there any truth to that?
Jul 28 '08 #7
oler1s
671 Recognized Expert Contributor
I should be able to look at the environment variables to tell what operating system it is,
You won’t need to though. If you have a windows binary, it won’t be running on a linux or a mac :)

...different compilers and even different compiler versions may not be able to compile compatible libraries...Is there any truth to that?
Very true. On example that annoys me: Python is built with Visual C++ 2003, and any third party extension modules must be built with same compiler version. Or I have to rebuild Python in another version, and then all the modules in that version.

It’s not so simple as black and white. If you keep reading about dlls, you should find information on compatibility issues, and how to deal with them.
Jul 28 '08 #8
Hero Doug
16 New Member
I was thinking of checking the environment variable so I wouldn't have to do any modification to the code.

I think I've gathered enough info to continue looking. I'll definately have to round up multiple compilers to develop a loader class, but I don't think it's going to have me too stressed out, in the end it (being able to load modules on demand without causing developer headaches) should be fairly generic which is what I want.
Jul 28 '08 #9
Banfa
9,065 Recognized Expert Moderator Expert
I was thinking of checking the environment variable so I wouldn't have to do any modification to the code.
Use compiler preprocessor symbols and conditional statements to conditionally compile the correct code for the platform.

The platform is set at compile time, to leave platform based decisions until run time is poor practice in my view.
Jul 28 '08 #10
Hero Doug
16 New Member
Yeah that's quite logical and makes sence, thanks for the tip.
Jul 28 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Jacek Generowicz | last post by:
I have a module whose behaviour needs to be configurable. The module needs to decide, the first time it is imported, beteween alternative interfaces it presents. Currently, I set some...
0
by: Jeff | last post by:
Ok, so I'm working on a project right now that is being done in psp through apache. This is working fine, except that in every one of my modules I had to use the mod_python function of...
5
by: nicolas_riesch | last post by:
Does someone know if the module pytz (http://sourceforge.net/projects/pytz/) is thread-safe ? I have not seen it explicitely stated, and just wanted to be sure, as I want to use it. That's...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
14
by: Roman | last post by:
I am trying to filter a column in a list of all html tags. To do that, I have setup the following statement. row = re.sub(r'<.*?>', '', row) The results I get are sporatic. Sometimes two...
10
by: Tom Plunket | last post by:
I've got a bunch of code that runs under a bunch of unit tests. It'd be really handy if when testing I could supply replacement functionality to verify that the right things get called without...
13
by: André | last post by:
Hi, i'm developping asp.net applications and therefore i use VB.net. I have some questions about best practises. According what i read about class and module and if i understand it right, a...
4
by: Peter J. Bismuti | last post by:
I'm having trouble understanding how namespaces work in modules. I want to execute a module within the interpreter and then have values that are calculated persist so that other modules that get...
1
by: Jeff Dyke | last post by:
I've come across an error that i'm not yet able to create a test case for but wanted to get see if someone could shed light on this. I have imported a module at the top of my file with import...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.