Hi,
I'm trying to call a DLL that I created using Microsoft Visual C++, and
ascertain that I created the DLL properly. I've never created a DLL
before, and the Microsoft documentation does not help me:
http://msdn.microsoft.com/library/de...attributes.asp
Also, if possible, I want to avoid using the Visual C++ wizard to create
a DLL, because that creates several files and extra lines of code.
Below is my test code. The first file creates a DLL with the function
"printHello()". The second file, the "main" program, tries to call that
function in the DLL. I believe the main program *could* find the DLL,
and that there is merely something wrong with my C++ syntax: I
remembered to put the DLL into the directory where the executable for
the main program was to be created, and set the PATH variable to search
the current "." directory.
** What is causing my DLL link error?
Thanks,
Suzanne
------------------------------------------
#include <stdlib.h>
#include <iostream>
__declspec(dllexport) println(char* s);
__declspec(dllexport) void printHello() {
std::cout << "Hello world\n";
}
------------------------------------------
#include <stdlib.h>
__declspec(dllimport) void printHello();
int main(int argc, char** argv) {
void (*f)() = &printHello;
f(); // Link error!!!
return EXIT_SUCCESS;
}