calling a DLL, using MS VC++

S

Suzanne Vogel

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/d...ng_the_dllexport_and_dllimport_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;
}
 
V

Victor Bazarov

Suzanne Vogel said:
I'm trying to call a DLL that I created using Microsoft Visual C++, and
ascertain that I created the DLL properly. [..]

It's not your first day here, is it? Don't you already know
that MS-specific questions are off-topic here? Please visit
microsoft.public.vc.language.
 
S

Suzanne Vogel

It's not your first day here, is it? Don't you already know
that MS-specific questions are off-topic here? Please visit
microsoft.public.vc.language.

Got it. Sorry.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top