Results 1 to 9 of 9

Thread: Linking to a dll

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    134

    Linking to a dll

    I made a dll project... and I made an exe project But I'm afraid I'm not sure how to link them. I went through another program I got a while back that does this but I still can't figure out how.

    [edit]BTW, I use MS VC++ 6[/edit]
    Last edited by Xerpher; Oct 20th, 2002 at 05:16 PM.

  2. #2
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196
    What do you want to do with them?

    From a project you can load a DLL through LoadLibrary and then access an exported function using GetProcAddress. Have a look in the MSDN libraries for linking to DLLs etc.

    Hope it helps.

    HD

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    134
    Thanks, but I still need one more thing... I like the example parksie posted but that uses VB and I looked through MSDN and just got more comfused

    So how exactly would I include my C++ DLL into my C++ Win App?

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You need to use the .lib file created when you linked the DLL in conjunction with the header file. That way it can link the functions implictly. Without them, you need LoadLibrary and GetProcAddress.
    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

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    This means you need to take the lib file that is created and list it in the linker input section of the project settings.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Ontario, Canada
    Posts
    134
    After its compiled, Do I still need to include the .lib file? or does it look for .dll when its compiled?

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Huh?

    You don't need to distribute the lib along with your app if that's what you want to know - all your app needs is included in the exe.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The .lib has information on which DLL actually contains the code, so no, you don't need the .lib afterwards.
    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