Thread: DLL's2

  1. #1
    Unregistered
    Guest

    Smile DLL's2

    i've been looking on the board but cann't find any clear infomation on this specific, is it posable to make DLL's with my "borland TC 1.01" compiler?
    if so could you point me in the right direction on where to learn how to do this?

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    I do not know if you can using that compiler. I know that LCC-WIN32 can do it. You can get it here -
    http://www.cs.virginia.edu/~lcc-win32/

    - Sean
    Last edited by sean345; 06-09-2002 at 01:11 PM.
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  3. #3
    I am the worst best coder Quantrizi's Avatar
    Join Date
    Mar 2002
    Posts
    644
    2nd website is worthless

  4. #4
    Unregistered
    Guest

    Smile

    thanks for your time.
    i'll probably start using a more modern compiler ive got micro visual c++ 6.0 intro, plus borland's builder 4.0 pro, but i like my TC 1.01, ar well thanks again.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I've been using version 3.0 and IT can't, so yours probably can't either. Mine is only capable of Object-module libraries. Version 4.5 can do a lot, so you won't have to get THAT modern in order to do it. I'd recommend that if you are going to do any serious programming, try and upgrade. A lot of websites give them away as free downloads. borland for one.

  6. #6
    Unregistered
    Guest
    Thanks Sean.

  7. #7
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    You're welcome Unregistered.

  8. #8
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You can't use DLLs officially, but you can emulate them. Granted you prob are not going to emulate the Windows standard DLLs, but you can use DOS LOAD via int 21h to dynamically load functions into memory (or a file). Then you must find a way to retrieve the address of the function you need. You could set up a type of vtable in the header of the DLL which would tell you the offset of the functions relative to where inside the segment the DLL was loaded. This would allow you to look up the functions by name and retrieve the address via a quick look up. However, to call this function you would either need to call it via a pointer, jump to it in asm (not recommended because it does not create a stack frame) or call it in asm.

    It is true that DLLs are really a compiler thing (in that they know how to create them to the MS standard) but you can emulate them with some tricks and techniques in DOS. Overlays are another area you might want to explore. DOS will load your code as an overlay if you tell it to - using the same function and interrupt I told you about.

    But for the most part you are prob stuck with using static libs in DOS unless you really know what you are doing in assembly.

    DJGPP can load DLLs but I've never done it so could tell you how to do it.

  9. #9
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I've done a lot of programming (at least enough to get to the point where most would've used a DLL), and never used a DLL. Firstly because I've never had a good tutorial on how to create and use them, and secondly I've never had a major need to, except for hwne I tried my first Windows program which was a complete disaster, probbably beacuase I didn't use a DLL for my icons. But what are DLLs and what are they used for? Could you also point me in the right direction to finding a good tutorial on them?

  10. #10
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    A DLL is a dynamicly linked library. They are similiar to static linked libraries. In a static library you create some functions and put them in the library. Then when your executable is compiled the library is linked with the executable.

    In a DLL you place some functions. At run time, the program loads the DLL and then has access to the functions in the DLL. The advantage is you do not have to recompile the executable when a change/update is made in the library.

    They are both similiar because they are just different ways to link with a library of functions. A DLL though, is more complex then just the functions you want. It has an entrance function (LibMain). Here is an example of LibMain:
    Code:
    BOOL WINAPI __declspec(dllexport) LibMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
    {
    	switch (fdwReason)
    	{
    		case DLL_PROCESS_ATTACH:
    			// The DLL is being loaded for the first time by a given process.
    			// Perform per-process initialization here.  If the initialization
    			// is successful, return TRUE; if unsuccessful, return FALSE.
    
    
    			break;
    		case DLL_PROCESS_DETACH:
    			// The DLL is being unloaded by a given process.  Do any
    			// per-process clean up here, such as undoing what was done in
    			// DLL_PROCESS_ATTACH.  The return value is ignored.
    
    
    			break;
    		case DLL_THREAD_ATTACH:
    			// A thread is being created in a process that has already loaded
    			// this DLL.  Perform any per-thread initialization here.  The
    			// return value is ignored.
    
    			break;
    		case DLL_THREAD_DETACH:
    			// A thread is exiting cleanly in a process that has already
    			// loaded this DLL.  Perform any per-thread clean up here.  The
    			// return value is ignored.
    
    			break;
    	}
    	return TRUE;
    }
    The __declspec(dllexport) means that these are functions that can be called the program that links the library. Besides that you just create your functions with __declspec(dllexport) and then you use the Windows API call LoadLibrary and you have access to the functions in the DLL.

    I put my commonly used functions in a DLL and then I can use the DLL in multiple projects. Also if I want to add another funtion to the library I do not have to recompile all the old executables, I just replace the DLL.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  11. #11
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Thanks! You know any good online tutorials for explaining the whole thing (like ALL the differences and not just the few you told me about)?. Thanks again.

  12. #12
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    I learned this stuff from the LCC-Win32 Tutorial. It contains a couple chapters on static and Dynamic libraries. It is in MS Word format and you can download it at ftp://ftp.cs.virginia.edu/pub/lcc-win32/tutorial.zip. See the sections on libraries, DLL's, and using DLL's. Hope this helps.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  13. #13
    Unregistered
    Guest
    it seems i've jumped in at the deepend again. Bubba i get the gist of what your saying but don't understand how to use the "DOS LOAD via int 21h" are you saying that you can run any function in memory if you call its starting address? i'm sure vtable stands for virtualtable but have no idea what a stack frame is.
    well.. looks like i have a lot more reading to do.
    thanks again for everyones help.

  14. #14
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    YOu might have to learn some Assembly for that, and thanks for the link Me345

Popular pages Recent additions subscribe to a feed