Linking dll in Visual Studio

前端 未结 4 978
春和景丽
春和景丽 2020-11-27 14:03

How can I add a .dll in Visual Studio 2010? I just cannot find the option there.

4条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 14:27

    You don't add or link directly against a DLL, you link against the LIB produced by the DLL.

    A LIB provides symbols and other necessary data to either include a library in your code (static linking) or refer to the DLL (dynamic linking).

    To link against a LIB, you need to add it to the project Properties -> Linker -> Input -> Additional Dependencies list. All LIB files here will be used in linking. You can also use a pragma like so:

    #pragma comment(lib, "dll.lib")
    

    With static linking, the code is included in your executable and there are no runtime dependencies. Dynamic linking requires a DLL with matching name and symbols be available within the search path (which is not just the path or system directory).

提交回复
热议问题