問題描述
如何將外部庫添加到由 Qt Creator RC1(版本 0.9.2)構建的項目中?例如win32函數EnumProcesses()
需要在項目中加入Psapi.lib
才能構建.
How can I add external library into a project built by Qt Creator RC1 (version 0.9.2)? For example, the win32 function EnumProcesses()
requires Psapi.lib
to be added in the project to build.
推薦答案
正確的做法是這樣的:
LIBS += -L/path/to -lpsapi
這樣它就可以在 Qt 支持的所有平臺上運行.這個想法是您必須將目錄與庫名稱分開(沒有擴展名和任何lib"前綴).當然,如果您包含特定于 Windows 的庫,這真的無關緊要.
This way it will work on all platforms supported by Qt. The idea is that you have to separate the directory from the library name (without the extension and without any 'lib' prefix). Of course, if you are including a Windows specific lib, this really doesn't matter.
如果您想將 lib 文件存儲在項目目錄中,您可以使用 $$_PRO_FILE_PWD_
變量引用它們,例如:
In case you want to store your lib files in the project directory, you can reference them with the $$_PRO_FILE_PWD_
variable, e.g.:
LIBS += -L"$$_PRO_FILE_PWD_/3rdparty/libs/" -lpsapi
這篇關于將外部庫添加到 Qt Creator 項目中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!