Skip to main content
GameDev.net gamedev.net
🔒 Locked

dlls includes?

Started by Chaucer Jan 11, 2003 at 12:45 AM 3 replies 200+ views
Original Post
Chaucer
Chaucer
I''ve been looking over this tutorial: http://gamedev.net/reference/programming/features/intdll/page2.asp and trying to implement my own dlls. The question I have is, Do I still need to include the headers to my classes? I thought if I loaded the library, I shouldn''t need to include the headers and if I was including the headers then the code was just being put into the exe anyway. Can anyone explain this? Even if I do need to include the headers each time, then why do I need to use "LoadLibrary" since it works without it if I''m including headers. Thanks!
Thanks!
Maega
Maega
The header needs to be included if you link with the static library of the dll (static linking to the DLL so you don''t have to mess with LoadLibrary, and so you can call the dll functions like they were in the program itself).

If you use LoadLibrary, the header can still be useful (for definition of function pointers) but it doesn''t need to be included.
dalleboy
dalleboy
If you have all your code in the h-file, there is little point in exporting and importing the class at all. But if there is code in a cpp-file you''ll need to export the class in the DLL and import the class in the EXE. You''ll need to include the h-file anyway you do it.

HTTP 500



Update GameDev.net system time campaign: ''date ddmmHHMMYYYY''
Metal Typhoon
Metal Typhoon
quote:
Original post by Chaucer
I''ve been looking over this tutorial:

http://gamedev.net/reference/programming/features/intdll/page2.asp

and trying to implement my own dlls. The question I have is, Do I still need to include the headers to my classes? I thought if I loaded the library, I shouldn''t need to include the headers and if I was including the headers then the code was just being put into the exe anyway. Can anyone explain this?


Even if I do need to include the headers each time, then why do I need to use "LoadLibrary" since it works without it if I''m including headers. Thanks!


here is what i found out after messing around TOOOOOO much with dlls ... if you end up crating a .lib file then you can use the .lib ,the .dll and the header for the function defs . The lib can be anywhere , the dll must be on c:\windows\system32 OR on the folder the .exe is being loaded, the header you know...


the other way is. is you dont create a .lib file you will use the header,the dll and LoadLibrary Functions... usually i do this i do two headers... the Mains .h will include the other.. the second .h will use LoadLibrary , which can let you put your dlls ANYWHERE ! which is good, to load the functions and so.
Metal Typhoon
mond
mond
quote:
The lib can be anywhere , the dll must be on c:\windows\system32 OR on the folder the .exe is being loaded, the header you know...

A partial truth. The loader first looks in the same directory as the executable, then looks in the current directory (or is it the other way around?), then starts looking in the system path. Since then "system32" directory is usually the first entry in the path, DLLs will be found there first, assuming they weren't in the first 2 directories.

I would suggest NEVER putting DLLs in system32 or any other system directory unless you ABSOLUTELY MUST. That directory is cluttered enough with DLLs, OCXs and other crap -- it doesn't need anymore from us! Place DLLs in your exe's directory, or add the directory in which you store DLLs to a user's path.

greg

[edited by - mond on January 11, 2003 12:01:46 PM]

[edited by - mond on January 11, 2003 12:02:03 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.