Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jtmerchant

EDIT:: Good DLL Tutorial?

This topic is 5238 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have code that I want to put in some sort of arrangement. Right now, I'm using headers and cpp files and I add the files to my project and the files stay in their folders. How would I make it so that all I have to do is include the header files without having to add them and the cpps to my project? I was thinking that I would use some sort of library, a .lib or a .dll, but I don't know much about either and I can't find a ground-up tutorial on either. [edited by - jtmerchant on January 14, 2004 7:10:23 PM] [edited by - jtmerchant on January 17, 2004 9:10:54 PM]

Share this post


Link to post
Share on other sites
Advertisement
You could indeed use a static lib or a DLL.

Static lib is easier, all you do is create a static lib project; bundle your Cpp files and compile it to a lib.

To use it; you need the header files and just simply link the library to your program at build time

Share this post


Link to post
Share on other sites
What about Dynamic Link Libraries?

EDIT:: Oh yeah, in static .lib files do you need to type in #include "(header).h"?

[edited by - jtmerchant on January 14, 2004 7:15:27 PM]

Share this post


Link to post
Share on other sites
Dynamic libraries are different; you have to explicitly state which functions to export from the DLL.

I create an interface (a class holding a load of members) and provide a Create() and Destroy() function from the DLL. This is based on Eric Wazoo''s (??) article here on Gamedev.

The DLL then be loaded by the exe; the handle is used to access the DLL''s functions (getprocaddress, I think). It can be a pain; unless you create a .def file and a static lib for the dll; then to use the dll you can again just link with the small static (which acts as a loader). Note with this way, you can''t use a ''plugin'' type architecture as the dll name and interface is then hardcoded to your app.

I suggest you have a look over at flipcode.com and at the DLL articles on here for more info. THe striving for Graphics independence article also helps understand the interface concept. If you''re having trouble; mail me.

Share this post


Link to post
Share on other sites
Umm, well I know a little about DLLs now, but does anyone know a walk-through tutorial on how to create and use them? I''ve looked here on GameDev and searched at Google and MSN, but the search terms I give don''t really give any good tutorials, so I''m back here.

Share this post


Link to post
Share on other sites
Hehe.. I''m kinda slow.. On the last one, it says the following in the DLL Sample\dll_test\dll_test.c file:
quote:
To use our new DLL, we need to include the header file which was used to compile it, and place the resulting .lib and
.dll file in this workspace so our test app can call the
functions exported by them.

What does he mean place the resulting .lib and .dll files in the workspace? I looked in his workspace and it looks like he "Project - Add to Project - Files"ed the .lib in but I can''t find how he added the .dll... Any help? Sorry, I''m not quite smart.

Share this post


Link to post
Share on other sites
The lib file takes out all the pain of having to acquire the module handle and get the function pointers to the exported dll functions.

If you are using abstract interfaces, you can''t do this - but if you have a single DLL, it will create a small lib file that handles the acquisition of the dll handle and will sort out all your referencing to it.

Think of when you use OpenGL - you *can* just use the H files and call a GetFunctionAddress(hModule, "func") - but you can also just link to the opengl.lib with loads and ensures you have the correct ogl dll file

Share this post


Link to post
Share on other sites
Right. The problem is, when I make my own projects, put the .dll and .lib in the test project''s folder, then add the .lib to the project, I get this error when I try to run my DOS program:
The application failed to initialize properly (0xc000007b). Click on OK to terminate the application.
I added the header file to the project too, but doesn''t work.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!