How to “add reference” in C++

前端 未结 4 913
不思量自难忘°
不思量自难忘° 2021-02-07 10:53

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

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-07 11:14

    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.

提交回复
热议问题