Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reference a DLL in a VC++ project

Tags:

visual-c++

I have a C++ driver I'm trying to compile, and it has this line in the code:

#import "msado15.dll" no_namespace rename("EOF", "EndOfFile")

But when I compile the project, I get the error:

Error 1 fatal error C1083: Cannot open type library file: 'msado15.dll': No such file or directory

I have the DLL, but where do I put it so that the compiler can see it?

like image 979
Craig Shearer Avatar asked Jan 05 '09 22:01

Craig Shearer


People also ask

How do I add a reference to a DLL in Visual Studio C++?

In Solution Explorer, select the project. On the Project menu, click Add References. In Visual C++, click References on the Project menu, and then click Add New Reference.

How do I use DLL in another project?

Solution 1Add a reference to the DLL directly to your new project: open your project in VS, expand the Project branch in the Solution explorer, then right click "References". From the context menu, select "Add Reference..." and wait for the dialog - If can take a little while to appear.

How do I add a reference to my Visual Studio project?

You can also right-click the project node and select Add > Project Reference. If you see a References node in Solution Explorer, you can use the right-click context menu to choose Add Reference. Or, right-click the project node and select Add > Reference.


3 Answers

You can place the DLL in the same path as the referencing file (.h) as you have done, alternatively you can modify the additional include paths for the LIB section of your project(s). In VC++ this will be:

Project | Properties | Configuration Properties | Linker | General | Additional Library Directories

This method can be useful if you are centralizing third party dependencies and you don't want to be forced to keeping the referenced file (.h) and DLL in sync via the same path.

See this MSDN link for further details.

like image 188
Henk Avatar answered Oct 31 '22 02:10

Henk


For VC++2010(VS2010): the compiler is not able to see the msado15.dll
which is located at C:\Program Files\Common Files\System\ado

Go to Project | Properties | Configuration Properties | VC++ Directories and add the following at executable directories

$(CommonProgramFiles)\System\ado;

You should be fine

like image 24
Ramakrishna Talla Avatar answered Oct 31 '22 02:10

Ramakrishna Talla


This may be a little out of date for most people, however - for Visual Studio 2008, for a particular

Project |
Configuration Properties |
C/C++ |
Additional Include Directories |

Select and click on the ellipsis (...).

Add the directory

C:\Program Files\Common Files\System\ado

and move it to the bottom of the list using the arrows.

like image 22
declanh Avatar answered Oct 31 '22 02:10

declanh