Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "add reference" in C++

I'm new to C++ and there's something I just completely don't get. In C#, if I want to use an external library, log4net for example, I just add a reference to the log4net DLL and its members are automatically available to me (and in IntelliSense). How do I do that in non-managed C++?

like image 846
John M Gant Avatar asked Jul 14 '09 19:07

John M Gant


People also ask

What is C# reference assembly?

Reference assemblies are usually distributed with the Software Development Kit (SDK) of a particular platform or library. Using a reference assembly enables developers to build programs that target a specific library version without having the full implementation assembly for that version.


1 Answers

Often, the library comes with 1) a header file (.h) and 2) a .lib file in addition to the .dll.

The header file is #include'ed in your code, to give you access to the type and function declarations in the library.

The .lib is linked into your application (project properties -> linker -> input, additional dependencies).

The .lib file usually contains simple stubs that automatically load the dll and forward function calls to it.

If you don't have a .lib file, you'll instead have to use the LoadLibrary function to dynamically load the DLL.

like image 77
jalf Avatar answered Sep 21 '22 05:09

jalf