Load .dll in VS2008 using C++ (Irrlicht as example)

Recently kick start my game project, my friend says I should try Irrlicht, so I try it.

But I know almost nothing about C++, especially how to link stuff together.

I follow their tutorial and compile okay. I know this is more than stupid to feel happy about it.

But I am still going to make a note on this in case somebody like me whats to know about this simle thing.

First of all, if you want to use someone else .dll, you have to have the .h and the .lib to use the .dll.

.lib is for static methods and also as a portal to the .dll dynamic methods. .h is the header file.

So, all three have to link to your project. in this order: .h -> .lib -> .dll

Secondly, how does the IDE find those file, for the .h, you can do it in two ways, globally setup in the IDE or locally setup in the project, I choose the second one.

open the properties of the project, Go to Configuration -> C/C++ -> general. There is a place to add ‘other include directories’. Add your directory which contains the .h there. You may have to add a source with int main() and the compile it in order to see C/C++ option.

For the .lib, go to linker -> general -> ‘other libraries directories’, Add the directory which contains the .lib there.

And there are two ways to link .dll, I only know what the tutorial taught me. write this in you code.

#pragma comment(lib, "Irrlicht.lib")

then copy the .dll to your project source root and you are ready to go.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s