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
The first thing you need to do is to #include the header file that describes the functions that are available in that library.
The actual code for the library will be in one of 2 places:
Depending on how the library's code is given to you (as .lib files, or as a .dll), you'll have to either:
Sometimes a package comes with BOTH a .lib file that you need to link to, and a .dll file. In this case you don't need to call LoadLibrary, you only need to #pragma comment( lib, "libaryfile.lib" ) because in this case the .lib links you into the .dll.
A very important detail is to put the DLL where your application can find it. Charles Petzold says:
When Windows needs to load a DLL module before running a program that requires it, the library file must be stored in the directory containing the .EXE program, the current directory, the Windows system directory, the Windows directory, or a directory accessible through the PATH string in the MS-DOS environment. (The directories are searched in that order.) Programming windows, 5th ed MSDN
I don't recommend using the project properties menu to link because it isn't as visible what libraries you're linking to.
See also