PDA

Click to See Complete Forum and Search --> : calling a dll in c++


Krushstone
Nov 17th, 2000, 10:13 PM
I know that it may sound stupid, but can anyone give me a generic code to call a dll in C++?

I looked on the web and I only found hot to call them from VB, wich is not a problem for me...

I have a dll and all the documentation, I just need to know how to call it...

shouldn't be too complicated :-)

thanks

parksie
Nov 18th, 2000, 08:20 AM
Did it come with any headers or libraries? Normally, you'd have the following:

A DLL, a header containing the function prototypes, and a stub library for the linker.

When you use this, the dynamic linking is resolved at compile time. Simply include the header and add the stub library to the list of libraries.

If not, then you can use run-time dynamic linking, which is much more complicated. What you need to do is to use the Win32 API calls LoadLibrary, GetProcAddress, etc. See here for an example of how to use it: http://www.parksie.uklinux.net/addin_fixed.zip

Krushstone
Nov 22nd, 2000, 10:26 AM
Ok, I have all the headers, dll and lib.
I added the header to my project, and the lib is in the section "ressource files"
but it just doesn't compile because of an unresolved external symbol.

So it can't find the function in the lib...
what did I forget to do?

thanks

parksie
Nov 22nd, 2000, 04:48 PM
Oops...I should have been clearer.

Copy the include to your normal includes folder (F:\vstudio\vc\include for me), then use it in your program as any other system include (#include <header.h>).
Copy the library to the lib folder, and go to Project Settings and choose the Link tab. Add the library file to the list you see.

Make sure that the header and library have been removed from the workspace, too.