CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Posts
    68

    Linking to DLLs with Visual Studio 10

    Hello,

    I have a library that I want to link to with Visual Studio 10. It is a dynamic-link library, with a .dll file and a .lib file. I am following what I think is the correct procedure for linking, but it is not working. Here is what I have tried:

    1. Add the directory of the .lib file to "Additional Library Directories".
    2. Add the .lib to "Additional Dependencies".
    3. Add the directory of the .dll file to "VC++ Directories / Executable Directories".

    Running this program tells me that it cannot find the required .dll file.

    The only way I can solve this is by manually copying the .dll file into the Debug or Release folder of my Visual Studio project. But isn't this the same as step 3 from above?

    Thanks for your help.

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Linking to DLLs with Visual Studio 10

    What I've always done is modify my PATH environment variable to include the path to the dll in Control Panels -> System -> Advanced. Either modify or create a user PATH variable, there's no need to edit the admin version.

    You will need to close and reopen Visual Studio before changes to the environment take effect.

  3. #3
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Linking to DLLs with Visual Studio 10

    Another way is to add the path in the debug settings environment. It's quite handy since you don't have to add path's for every single project you work on.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

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

Featured