views:

114

answers:

2

Hi, I have created a project VC++ in VS 2008. I want to call a certain function in an external dll.

How can I add the reference/resource [I am a java guy please forgive if I am using the wrong terms here] to my project so that I can call the functions in the dll.

I have gone through several forums and yet have not found a clear solution.

Please help. TIA Ayusman

A: 

This is for VC6, so some of the property pages are slightly different in VC9, but it captures the essence of it.
http://www.codeproject.com/KB/DLL/XDllPt1.aspx

Kyle Alons
A: 

You need 2 things:

  • the header file for the DLL's exported functions
  • an 'import library' that needs to be added to the linker's list of libraries to link against

Adding a header is done by placing it to a directory that gets searched by the project's "Include Directories" (or add the directory the header is in using the project's "C-C++/General/Additional Include Directories" setting). Unfortunately a header file might not be found during a build simply by adding the file to the project.

Adding a .lib file is done in Visual Studio in the C++ project's properties under "Linker/Input/Additional Dependencies"

At runtime the DLL will need to be in the same location as the .exe file or it needs to be in a directory searched by the path.

Michael Burr
Perfect. It helped.Thanks.
Ayusman