Archived

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

How do I use DLLs and LIBs?

This topic is 6116 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

First off, how do I use DLLs? Secondly, if I can just link DLLs and LIBs with my projects, like ddraw.lib, why do I have to #include the headers, like ddraw.h? If we can just #include the headers, why do we need libraries? Also, what is the difference between a DLL and a LIB? Edited by - Some Guy on March 14, 2001 8:54:20 PM

Share this post


Link to post
Share on other sites
You can load a DLL static or dynamic:

static == linking with the LIB that belongs to the DLL.
dynamic == loading the DLL directly from your app with LoadLibrary(..) without needing a LIB file.

header == definition of classes, variables, inlined code, preprocess, etc.
dll == actual code of what''s defined in the header.

The difference between a DLL and a LIB is that a DLL needs to be loaded everytime with your program and a LIB is statically linked to your program at compiling time.
They can both have code inside..

Hope I''ve explained it good enough...
Sorry, no links for how to use them because I need to go now..

(but you can create a sample DLL/LIB with the MSVC Appwizard)

Share this post


Link to post
Share on other sites
Yes gamedev just had a tutorial.. look in the developer sec uner articles/tutorials for... "How to make a static lib"

Making static libs are the easiest thing inteh world to do.

If you have MSVC 6 just goto NEW->create static library->empty project...

And write code like classes and function in the .cpp file and in the header file function prototypes and class declarations. ( You dont need a int main() function for libs by the way. )

When U compile a .lib file will result INSTEAD of an exe... simple as that...

When U what to use the code in the lib you add the lib ( like another other file to your project) and include the libs header. Now since you have the declarations from the header and the .lib file that actually HAS the code to use the functions you can call the function like normal...

( by include .lib there are 2 ways that i know of...

1 - right click a folder in your project window and ADD NEW FILE.
2 - OR goto project->setting->link tab and add yourlib.lib in with the rest...

hope that helps and yea libs are great as they are modular and if you anna share em you dont have to completely reveal your code...

Share this post


Link to post
Share on other sites