🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
DLL Files?
I know this isn''t directly OpenGL related, but I''m trying to write a particle engine-based game using a DLL file I wrote for the main particle functions. I''m using __declspec(dllexport) and import to make the functions availible, but I can''t figure out how to actually include the DLL file in my main .CPP file... any help would be appreciated.
Pathos
Ok. When you compile a DLL, you have a .lib file, which you need to link to your app. Then, to call your functions, you have to include your header (.h) which contains _declspec(dllimport) declarations of your functions.
I can be more precise if you want to.
EL
----------------------------------------
"Inash neteia haeg joa kavari quilm..." SD4
I can be more precise if you want to.
EL
----------------------------------------
"Inash neteia haeg joa kavari quilm..." SD4
I think clarification would help. I''m not completly clear on what exactly I should do. Thanks for the help.
All right. I'll give you some source code :-)
MYDLL.CPP is your DLL, which you compile with MYDLL_EXPORTS defined. You can then use your DLL in MYPROJECT.CPP, which you compile without MYDLL_EXPORTS. When you build your DLL, you'll have the .dll and a .lib, which you link to your project (MYPROJECT.CPP).
I typed everything from memory, so there might be some errors. Read the example, and figure out what I did. It's easy.
EL
(Edition: I added /**/ at the end of many lines to keep some formatting. The message board has some problems with #defines and other commands)
(2nd Edition: It didn't worked . Oh well, you are smart enough to figure it out :p)
----------------------------------------
"Inash neteia haeg joa kavari quilm..." SD4
Edited by - Demon Lord on July 27, 2000 8:11:14 PM
Edited by - Demon Lord on July 27, 2000 8:12:55 PM
FILE MYDLL.H------------#ifndef _MYDLL_H_ /* Sentinel */#define _MYDLL_H_/* Set some definitions. When you build the DLL, define MYDLL_EXPORTS somewhere (like in your project options) */#ifdef MYDLL_EXPORTS #define MYDLL_API _declspec(dllexport)#else #define MYDLL_API _declspec(dllimport)#endif/* C++ does some "smart" function name conversions. It sucks if you want to use anything else than C++ */#ifdef __cplusplusextern "C" {#endifMYDLL_API int Add(int a, int b);/* Close the "extern "C"" statement */#ifdef __cplusplus}#endif #endif /* _MYDLL_H_ */FILE MYDLL.CPP--------------#include "MYDLL.H"/* extern "C" again, or you'll have a different declaration problem */#ifdef __cplusplusextern "C" {#endifMYDLL_API int Add(int a, int b){ return (a+b);}#ifdef __cplusplus}#endifFILE MYPROJECT.CPP------------------#include "MYDLL.H"#include <iostream.h>int main(){ cout << Add(1,2) << endl; return 0;}
MYDLL.CPP is your DLL, which you compile with MYDLL_EXPORTS defined. You can then use your DLL in MYPROJECT.CPP, which you compile without MYDLL_EXPORTS. When you build your DLL, you'll have the .dll and a .lib, which you link to your project (MYPROJECT.CPP).
I typed everything from memory, so there might be some errors. Read the example, and figure out what I did. It's easy.
EL
(Edition: I added /**/ at the end of many lines to keep some formatting. The message board has some problems with #defines and other commands)
(2nd Edition: It didn't worked . Oh well, you are smart enough to figure it out :p)
----------------------------------------
"Inash neteia haeg joa kavari quilm..." SD4
Edited by - Demon Lord on July 27, 2000 8:11:14 PM
Edited by - Demon Lord on July 27, 2000 8:12:55 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement