[英]How to use hdfk library into qt?
將庫添加到Qt項目實際上非常簡單。 在qmake .pro文件中,您需要以下內容:
# This is the search location for the compiler to look for headers that accompany your library.
# For system libraries that typically resides under **/usr/include** or **/usr/local/include** if you used `make install`.
INCLUDEPATH+="/path/of/headers/for/library"
# This is the search location for the compiler/linker to look for the library itself.
# For system libraries this is usually somewhere under **/usr/lib** or **/usr/local/lib**
LIBS+= -L/path/of/library/itself
# This is the name of the library to include at link time
# without the **lib** prefix and the **.so** / **.a** / **.lib** / **.dll** extension.
LIBS+= -lMyLibraryName
# This is the full path of the library file itself
# *including* the aforementioned **lib** prefix and the **.so** / **.a** / **.lib** / **.dll** extension.
# This is used by qmake to look for changes to the library at build time,
# to make sure it is re-linked on change and other dependency related stuff
PRE_TARGETDEPS += /path/and/filename/of/library/itself/libMyLibraryName.lib
提示:所有路徑,除非它們被指定為絕對路徑 (以'/'開頭)將相對於構建目錄 。 這可能是項目目錄,但在陰影構建的情況下,它將是陰影構建目錄 。 作為提示,只需將以下內容添加到您的相對路徑中,使它們相對於項目目錄: $$_PRO_FILE_PWD_/
so如果您的lib位於/my/qt/project/libs/mylib
您可以使項目適應移動通過使用$$_PRO_FILE_PWD_/libs/mylib
來代替。 請注意,“project dir”是qmake .pro文件的位置。
我使用https://www.cryptopp.com的 CryptoPP HKDF實現
首先,為有效的架構和您的平台(MacOS,Android,iOS等)構建靜態庫。 CryptoPP Wiki有工作手冊和腳本。
然后,只需在qmake * .pro文件中添加2行:
INCLUDEPATH += $$DEV_LIBS_PATH/cryptopp/$$ANDROID_ARCH/include
LIBS += -L$$DEV_LIBS_PATH/cryptopp/$$ANDROID_ARCH/lib -lcryptopp
你可以理解,我使用了qmake變量DEV_LIBS_PATH和ANDROID_ARCH,這些變量只是構成相關頭文件和靜態庫libcryptopp.a
正確路徑。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.