博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于QT加载lib与dll的一点评论
阅读量:4301 次
发布时间:2019-05-27

本文共 1672 字,大约阅读时间需要 5 分钟。

      On Windows, you always link against a .lib file, even if the library itself is in a DLL. What you normally have to do to use an external library, on any platform, is:

1) Add the library to the LIBS variable in your .pro file:

  1. LIBS += -llibrary

2) Add the library path to the LIBS variables in your .pro file:
  1. LIBS += -LC:/path/to/library

3) Add the include path to the INCLUDEPATH variable in your .pro file:
  1. INCLUDEPATH += C:/path/to/includes

   Then, if the library is a DLL, you must make sure the DLL is found when you run the program. On Windows you can e.g. add it the same directory as your executable. If you run the application from Qt Creator, it seems to be able to locate the DLL itself (if it’s in the same place as the .lib file, I would guess).

     Just to clear it up.. You can choose to link statically or dynamically, statically meaning the library is bundled along with your app, dynamic uses a dll. Now, if you have a .lib and a .dll, you have a library made to be used dynamically. You cannot use that .lib file statically, the static .lib is generally named (<somename>_a.lib), is of a bigger size than the .lib in the case of dynamic libraries. This is because the static .lib has to contain all the implementation, while in the dynamic .lib, you only have the exported symbols, and the actual implementation is in the dll.

      @matthazley: You have a .lib and .dll but do you also have the header files (.h).. that is the general way to link to a library. You include the header in your code and use the methods. Compile with linking to the .lib. At runtime this loads the dll which has the implementation. Refer to @ludde for the definitions in the pro file.

转载地址:http://fjxws.baihongyu.com/

你可能感兴趣的文章
Android 面试题整理总结(一)Java 基础
查看>>
Android 面试题整理总结(二)Java 集合
查看>>
学习笔记_vnpy实战培训day02
查看>>
学习笔记_vnpy实战培训day03
查看>>
VNPY- VnTrader基本使用
查看>>
VNPY - CTA策略模块策略开发
查看>>
VNPY - 事件引擎
查看>>
MongoDB基本语法和操作入门
查看>>
学习笔记_vnpy实战培训day04_作业
查看>>
OCO订单(委托)
查看>>
学习笔记_vnpy实战培训day05
查看>>
学习笔记_vnpy实战培训day06
查看>>
Python super钻石继承
查看>>
回测引擎代码分析流程图
查看>>
Excel 如何制作时间轴
查看>>
股票网格交易策略
查看>>
matplotlib绘图跳过时间段的处理方案
查看>>
vnpy学习_04回测评价指标的缺陷
查看>>
ubuntu终端一次多条命令方法和区别
查看>>
python之偏函数
查看>>