Dynamic loading of classes. 
Author Message
 Dynamic loading of classes.

Hi.

First of all, apologies if this is the wrong group for this - but this one
seems a bit more friendly towards new posters than comp.lang.c++...

I have an app that applies effects to wave files.  Each effect is, at
present, a class included in the main source, statically linked at compile
time.  I'd like to be able to develop the effects separately from the main
app, and load them at run time.

Can anyone give me a pointer as to how this could be done?  Or what
Microsoft call this kind of behaviour? - I come from a Java background, so
half of the battle in VC++ is learning what everything's called now...

Thanks for any help.

Matt Haney.



Tue, 30 Jul 2002 03:00:00 GMT  
 Dynamic loading of classes.

Quote:

> Hi.

> First of all, apologies if this is the wrong group for this - but this one
> seems a bit more friendly towards new posters than comp.lang.c++...

> I have an app that applies effects to wave files.  Each effect is, at
> present, a class included in the main source, statically linked at compile
> time.  I'd like to be able to develop the effects separately from the main
> app, and load them at run time.

> Can anyone give me a pointer as to how this could be done?  Or what
> Microsoft call this kind of behaviour? - I come from a Java background, so
> half of the battle in VC++ is learning what everything's called now...

> Thanks for any help.

> Matt Haney.


DLLs - Dynamically Linked Libraries - are the basic solution.  There are several
variations, including implicit linking DLLs, explicit linking DLLs and ActiveX
controls, which are DLL's but come in OCX files.  You can set up a project in VC
to create a DLL or to create an ActiveX control.  If it's just for use in your
own program the DLL is probably easier.  For program-controlled loading and
linking you load the DLL with LoadLibrary() and get its function addressses with
the GetProcAddress() API.  

--
Scott McPhillips [VC++ MVP]



Tue, 30 Jul 2002 03:00:00 GMT  
 Dynamic loading of classes.
Matt,

Quote:
> First of all, apologies if this is the wrong group for this - but this one
> seems a bit more friendly towards new posters than comp.lang.c++...

> I have an app that applies effects to wave files.  Each effect is, at
> present, a class included in the main source, statically linked at compile
> time.  I'd like to be able to develop the effects separately from the main
> app, and load them at run time.

> Can anyone give me a pointer as to how this could be done?

I'd probably decide to put the effects on dlls. Each dll would have a known
exported function that acted as class factory for the class, and that would
give you a pointer to the  effect class. It's simple and easy to implement.
If you'd like to go a little bit farther, you can use COM for this, it's
pretty well suited for that kind of task (many people avoid com as much as
they can,though, me included sometimes <g>).

Also, it's worth noting that you can export the classes directly from your
dlls, but there are problems with that approach (versioning, etc) that I
prefer to avoid.

--
Tomas Restrepo
http://members.xoom.com/trestrep/



Tue, 30 Jul 2002 03:00:00 GMT  
 Dynamic loading of classes.

Quote:
> First of all, apologies if this is the wrong group for this - but this one
> seems a bit more friendly towards new posters than comp.lang.c++...

Most people here follow both newsgroups.

Quote:
> I have an app that applies effects to wave files.  Each effect is, at
> present, a class included in the main source, statically linked at compile
> time.  I'd like to be able to develop the effects separately from the main
> app, and load them at run time.

Difficult to say what to do in a factual vacum, but "use DLLs"  is perhaps
the obvious answer.

Quote:
> Can anyone give me a pointer as to how this could be done?  Or what
> Microsoft call this kind of behaviour? - I come from a Java background, so
> half of the battle in VC++ is learning what everything's called now...

Perhaps posting your Java code  would help. We can than try to translate it.
If you have developed any C++ code, post that.

NeilB



Wed, 31 Jul 2002 03:00:00 GMT  
 Dynamic loading of classes.

Quote:

> DLLs - Dynamically Linked Libraries - are the basic solution.  There are
several
> variations, including implicit linking DLLs, explicit linking DLLs and
ActiveX
> controls, which are DLL's but come in OCX files.

<snip>

Thanks for the speedy replies.  I had gathered this was more or less the
route to
take but verification is always nice. Now that I know I'm on the right track
I'll have a
go at figuring out the finer details for myself.

Out of interest, is there a platform-independant way of doing this kind of
thing?

Thanks,

Matt.



Thu, 01 Aug 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. dynamic class loading

2. Using class object in a dynamic loaded DLL

3. dynamic loading class from dll

4. dynamic CFormView class creation in a CTreeView class

5. Dynamic Loading in C or C++

6. Dynamic loading in different OS's

7. How can i dynamic load a windows form ?

8. dynamic DLL loading and unloading

9. loading dynamic libraries

10. Dynamic Loading of C programs

11. dynamic loading

12. Dynamic loading

 

 
Powered by phpBB® Forum Software