How to reference a (dynamic Lib) DLL in a Visual Studio 2012 C ++ project?

I created a dynamic library with compiled headers and compiled a DLL (using Visual Studio 2012).

I also have a C ++ project, created also with Visual Studio 2012, which I want to refer to the previous created DLL.

How to reference this (dynamic Lib) DLL in my Visual Studio 2012 C ++ project? Do I also need to specify a header file (.h) if I want to use library functions?

+4
source share
4 answers

The easiest way for me is to refer to the DLL project using the Framework and References element in the project properties dialog:

enter image description here

It sounds like you are adding some strange .Net thing to your own C ++ code, but this is also the easiest way for a project with internal code to reference another.

If you want to call functions in this DLL, then yes, you probably want to include this DLL header file.

+4
source

There are several ways to do this, but everyone has in the comm that you need to include the title in your project so that the functions are known, since C ++ is not reflected.

  • you can skip the binding statically and load the DLL using LoadLibrary and get the functions using GetProcAddress, this has the advantage that you can make the DLL optional. If this is not the case, you could simply not call it or give some convenient error message.

  • you can statically refer to a DLL, this means adding a DLL file to the DLL project, there are several ways to do this, the old school method is to add it to the properties of your solution / linker / input / additional dependencies, and then make sure that the dll is in the search path exe. You will receive an error message if it is not found.

+1
source

Here you can see the documentation: http://msdn.microsoft.com/en-us/library/ms235636(v=vs.80).aspx (creating and using a dynamic link library)

0
source

I can give you an answer on how to add dll in VS 2010

steps: right-click on the solution explorer, properties, configuration properties, General, output directory. click the right arrow here and select eyebrows. go to the dll directory.

thats all.

-1
source

Source: https://habr.com/ru/post/1442170/


All Articles