Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / General Programming / Exporting/importing classes from a DLL. Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
JBL

May 12, 1999, 05:43 AM

Hi folks,
I would really like to see how to export/import a class from a DLL in plain C++ for Win32. I haven't seen any code for that on either MSDN or any books i have.

So if any 1 here know how to do that without COM or MFC, let me know :)

Cheers, JBL.

 
Jaap Suter

May 12, 1999, 06:45 AM

Can you please explain why you do not want to use COM? I can understand you don't
want to use MFC. But COM is really cool and way more easier and cleaner after you have been
trough the initial learning hassle.

I wanted to do the same thing as you: "export a class from a dll" but somebody reccommended
COM instead and i do not regret delving into COM.

Goodluck anyway

Jaap Suter

 
JBL

May 12, 1999, 07:45 AM



Jaap Suter wrote:
>>Can you please explain why you do not want to use COM? I can understand you don't
>>want to use MFC. But COM is really cool and way more easier and cleaner after you have been
>>trough the initial learning hassle.

I basically want to stay away from as much MS specific stuff as possible. Porting to Linux would be another reason.
I don't know much about COM, so i might be mislead ;).

>>I wanted to do the same thing as you: "export a class from a dll" but somebody reccommended
>>COM instead and i do not regret delving into COM.

The strangest thing is that i can't find any example anywhere.

>>Goodluck anyway
>>
>>Jaap Suter
>>

Thanks

 
Jaap Suter

May 12, 1999, 09:15 AM

First of all I would like to state that although COM is a Microsoft invention it
is already supported on macintosh, unix and soon linux.

Crystal Space uses COM and that works on Linux too.

For the example bit. You're right, when i wanted to delve into COM i found there was
absolutely nothing written about it. I have a couple of suggestions:

1. Buy a book, i have several reccomended on my COM tutorial and you won't regret it
2. Search for a link. www.microsoft.com/com is cool and my COM tutorial has some more.
3. Search for doctor GUI on COM somewhere on msdn.
4. Read future articles on COM by me. The next article will be uploaded friday.

If you got any questions do not hesitate to mail me. I really like COM and helping people
with COM. I'm in no way a com expert but by learning other people I can learn myself

Jaap Suter

 
Timo

May 15, 1999, 06:40 PM

to share classes between a DLL and a main App,
you have to define your base classes as pure virtual
in the DLL header, and implement them in sub classes
in your DLL.

and yes .. you can also use COM ..

Timo

 
Thierry Tremblay

May 19, 1999, 08:00 PM

Look at the Frog engine (http://frogengine.net-connect.net) it use classes in DLLs.
The reason I didnt use COM is that I needed polymorphism and you can't have that with
COM. If you don't need polymorphism, I definitely recommand using COM or simple function tables.

Thierry

 
Kevin Smith

May 22, 1999, 01:43 AM

The basic problem to be solved when exporting classes via dlls is the linker's ability to resolve the member function names and addresses. If you're using VC 5.0 (like me), I've got a test project I could send you to illustrate the fix.

Basically, do the following:

1. Implement your classes in the dll project. Each _public_ member declaration (in the header file) should be prefixed with the following MS-specific stuff: __declspec(dllexport)

2. Compile your dll and lib

3. In the client program which will use the dll, link in the newly created lib, #include the header files for the classes and make sure the dll is in your path.

Not real dynamic but it works :) You can simulate COM's dynamic loading via virtual base classes and polymorphism. hmm.... might make a good article....

Mail me if you have any questions...

 
This thread contains 7 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.