Qbasicnews.com

Full Version: How do I create a DLL and acces its functions from FB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I know this has been asked before in various topics.
I just cant understand it, sry.

Anyone care to explain it?


I create a DLL in fb how?
I know i need a *.a file to be able to use it, how do i make *.a files?
fbc -dll mydllcode.bas at the commandline.
This will create a console dll file and it should also create the .a file as well. If by some chance you lose the .a file, but still have the dll file, you can use Nek's makea program to regenerate the a file.

Be very sure you've included the DLLMain function in your primary source code. *cough*use the DLL example file as a template*cough*
Smile
Yeah, anything you must know is shown at examples\dll, i added a bunch of comments this time, er.

The import library (.a) is created automatically when -dll is used (besides the .dll, course).
How much slower is a repeated call to a DLL compared to a repeated call within the program itself?

I know nearly nothing about DLLs so...

The first call (pre DLL load) would be slow, right, but consecutive calls, fast?, slow?


Extreme example: A pset function inside a DLL
Would it work at all, or just be slow as crappy shit Big Grin


What do you recomend should go in DLLs? I want to use DLLs, it would make it much easier to make fixes for various stuff later on, and I wouldnt need to recompile my entire source each time I change something.
Compile has started to take noticable time now, my source is over 300KB, compile runs at about ~10-15sec Tongue
Common functions that you would like to use in more than one program are what you put into a DLL. It's really not much different in concept than making a QLB/LIB in QB, except the fact that multiple programs can access the DLL at once. Making calls to a DLL shouldn't have any speed difference than if you were to statically link the same functions, but it is possible that I am wrong (although I doubt it highly, I've been working with DLLs for years now...).
I recall, in a not to distant past, that people would create DLLs to Accelerate functionality. Hence, I would even assume, by the way a DLL (is or maybe was if it changed since the coming of COM/DCOM and Active X) that a simple function library DLL would actually execute FASTER in a DLL

So I agree with the other old timer Adosorken (Nek) he who has a thousand names for a thousand moods LOL. Slower is just about out of the question ;-). Faster well that depends how much they changed DLL's in the past 10 years LOL...so at least the same speed is my answer....final answer...;-)
Naw, not faster... actually a bit slower (one or two extra jumps, depending on how the compiler generates code).
DLLs are useful in gathering together functions that will be loaded into memory at the same time... instead of loading 20 copies for 20 separate instances of a lib, dynamic linking allows the library code to be loaded just once and reused (mapped into multiple process' memory spaces).