What is my main concern is , I am able to write a C++ dll using VC++ . Now the dll is present in the Debug folder.
How can I use my DLL in other C++ Console Application. How to add reference or link the DLL to the application.
Another point, While creating a DLL , The VC++ wizard gives me thre option:
Now as per article from CP I have used the 3rd option. (Unable to follow as the dll was used by an MFC app, Some how little advanced at this point of time)
Do I need to always choose the third option? What are the the other two options mean?
Not completely sure what you questions are but:
It doesn't really matter which option you use it is just a matter of what the wizard does for you; if you use the third option then the wizard creates a bit in your header file that looks like this:
#ifdef TEST_EXPORTS
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif
The way this works is that in the DLL project TEST_EXPORTS is defined in the compiler options so TEST_API evaluates to dllexport thus telling the linker to export these symbols. If you include this header in another project it defines TEST_API as dllimport which tells the compiler to link to it at run-time in the DLL. This #define method of exporting symbols is widely used and easy to read.
In order to call a function/class inside the DLL you need to export the symbols one of two ways: a) using the __declspec(dllexport) [this seems the more convenient option in almost all cases ]OR b) using a .DEF file in your project
Also wanted to mention that you need to include either the DLL project in your solution for the .exe file OR the .lib generated by the DLL compile.