Advertisement

Updated DLL and Interfaces article

Started by February 21, 2000 09:02 PM
3 comments, last by Skid 24 years, 6 months ago
Heyo, I just updated the my "DLLs and Interfaces" article with more information and corrections. Would appreciate any feedback if anyone gets a chance to read it. http://www.thepeel.com/void/tutorials/tut4-dll.htm Thanks.
First of all I want to say that your article is worthy of recommending to people that want to learn DLL programming or people moving into COM. Definitely has a COM flavor to it.

Now for the part where I sound like a jerk or show my ignorance:

quote: When using RunTime linking, the client doesn''t rely on the OS but loads the DLL explicitly in the code when it wants to. Furthermore it doesnt need to link to any .lib files so you don''t have to recompile the client just to link to a newer lib file.
...
DLLs designed for RunTime linking usually use .def files to define the functions they will export. If you don''t want to use .def files then you can just prefix the C functions to be exported with the __declspec(dllexport) keyword. Both of these methods accomplish the same thing.



The only problem I have with this is the fact that in order to do away with a DEF file you would have to include the following in order to build the executable using the __declspec(dllimport/export) method:

1. The header file -- no problem here
2. The .lib file -- you have to resolve linkage in the exe
3. The .dll -- This being the only thing the "user" would need ( with the executeable of course )

While that does do away with using DEF files you bring back the problem of having to re-compile the executable as you effectively "do away" with the ordinals that make runtime dynamic linking work in the first place. ( Modifing only the dll and distributing it to the client )

Hopefully my concern/question is clear:

DEF method = Allows rebuilding/redistribution of the dll without re-compiling the exe.

__declspec(dllimport/dllexport) = Can''t modify dll without re-compiling the exe.

Again, the article is very cool. If you have knowledge or a trick that I lack about the point I brought up by all means educate me ( and others ).

-- deadlinegrunt

~deadlinegrunt

Advertisement
my turn to sound like an unregistered jerk:

__declspec(dllimport/dllexport) = Can''t modify dll without re-compiling the exe.

sadly, this is wrong. If you need proof or others have questions, post a reply. I just fired off an email to Skid about the same topic.
Heyo,

Anonymous is absolutely correct. That part isn''t worded correctly. You CAN use __declspec(dllimport/dllexport) and recompile the DLL without having to recompile the client, as long as you don''t change what the DLL is exporting.

"... dependencies so that the client code will have to be recompiled each time the DLL code changes and generates a new .lib file."

What I should have said here is that whenever the exported items in the DLL change. Not when its recompiled and generates a new .lib file which is exactly the same as the one the client linked to before.

I just uploaded tiny zip file containing a DLL project i just whipped up using the VisualC++ AppWizard. First of all just compile both of them to make sure they work. Then uncomment a line from the DLL''s exported functions, and run the client again. You will see the client is able to use the same DLL and calls the correct function even though its implementation has changed.

You can get the file at
http://www.thepeel.com/void/files/Dlltest.zip

Thanks a lot for the feedback.
First of all my previous post was indeed, WRONG.

I was playing around with that earlier today and found the mistake I was making. I don''t use VB enough to say I can, and the only way I could ever link outside of C++ to VB was the method I was talking of, excluding hiding the implementation in a COM flavor. And posting irregardless of that fact, I have indeed showed my ignorance.

I chose to leave the post up rather than delete it so to avoid looking like a chicken sh-t, sadly. That coupled with that fact I''m just now getting back to posting my "err"

So, as before, the article is worthy of anybodys attention of reading for the information it contains -- just like I said before, that still hasn''t changed.

~deadlinegrunt

This topic is closed to new replies.

Advertisement