Results 1 to 4 of 4

Thread: calling a dll in c++

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Québec City
    Posts
    73
    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

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Québec City
    Posts
    73
    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

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width