繁体   English   中英

如何使用hdfk库进入qt?

[英]How to use hdfk library into qt?

如何在我的qt项目中使用HKDF库? 我发现这个库在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.

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