简体   繁体   English

在Visual Stucio C ++ 2008中链接库(.lib)和(.dll)

[英]Linking library (.lib) and (.dll) in visual stucio c++ 2008

I've generated my libmodbus library with visual studio 2008. I can see the .dll and the .lib files. 我已经用Visual Studio 2008生成了libmodbus库 。我可以看到.dll和.lib文件。

Now in my project I can use this library if I configure my project: 现在,在我的项目中,如果配置我的项目,则可以使用此库:

  1. Linker Additional directories. 链接器附加目录。 (.lib folder) (.lib文件夹)
  2. Additional libraries (.lib file) 其他库(.lib文件)
  3. C/C++ Aditional directories. C / C ++附加目录。 (Library code path) (库代码路径)

With this steps everythings works fine. 通过此步骤,一切正常。

But, is it possible to do the same without have the source code? 但是,如果没有源代码,是否可以这样做? Only with my generated .dll and .lib files? 仅使用我生成的.dll和.lib文件?

You do not need source files for use dll. 您不需要使用dll的源文件。 All you need is .dll file. 您只需要.dll文件。 But in this case you should manually get address of every used function. 但是在这种情况下,您应该手动获取每个使用功能的地址。 Example for widows you can find here . 寡妇的例子,您可以在这里找到。

Getting address of every function is not very convenient. 获取每个功能的地址不是很方便。 So you can use .lib file and header files (.h) (but not sources). 因此,您可以使用.lib文件和头文件(.h)(但不能使用源文件)。 In C/C++ Additional directories you should specify path to header files. C/C++ Additional directories您应该指定头文件的路径。

So you can configure your project: 因此,您可以配置项目:

  1. Linker Additional directories. 链接器附加目录。 (.lib folder) (.lib文件夹)
  2. Additional libraries (.lib file) 其他库(.lib文件)
  3. C/C++ Aditional directories. C / C ++附加目录。 (Library headers path) (库路径)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM