本文共 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:
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/