really, really basic DLL use
Heya, I'm a mostly UNIX C++ programmer who is trying to transition into Windows programming, and I would like to know how to create and call a DLL. I am used to the "compile as a shared library, declare as extern, and pass the library's name to the linker through the command line" paradigm. I have examined numerous Windows tutorials that don't address the starting points. My question (and please point me to a tutorial that covers this if you know of one):
1. What special commands do I put into a program if I want to compile it into a DLL?
2. What special commands to I put into the program that calls the function in the DLL?
3. What kind of compiler/linker options do I need to use, specifically for Borland command-line tools?
If it would make it easier, lets use an example:
Let's say I want to compile the following program into a DLL:
Code:
#include <iostream>
void hello() {
std::cout << "Hi there!" << endl;
}
Normally I would use the following syntax in the calling program:
Code:
extern void hello();
int main() {
hello();
}
Then I would compile the first code with the -G command in the CC compiler to create a dynamically shared library, and compile the second with the -l command which tells the linker to look in the hello library for the hello function. So, if you please, take these code snippets and add to them the necessary verbiage for DLLs.