在 Windows 7 上安装 QCA-OSSL(Qt 加密架构的一部分)插件时出现问题

发布于 2024-10-10 12:41:32 字数 1522 浏览 1 评论 0原文

我已经尝试在我的 Windows PC 上使用 QCA(链接)几天了,可以正常工作在我的 Linux 机器上没问题,只是无法在 Windows 上运行。

所以我遵循了安装 QCA 的所有说明,然后安装了 QCA 的 ossl 插件。 QCA 工作正常,但由于某种原因,该插件没有显示在我的 Qt Creator 中,我也无法使用该插件中的某些功能。

我使用 QCA 附带的 qcatool2.exe 来检查我使用的插件

qcatool2 plugins --debug

并收到此错误消息:

plugin: qca-ossl2.dll: failed to load: The plugin 'C:/Qt/2010.05/qt/plugins/ crypto/qca-ossl2.dll' 使用不兼容的 Qt 库。预期的构建密钥“Windows mingw debug full-config”,得到“Windows mingw release full-config”

现在在我看来,好像qt需要在调试模式下编译插件(以便获得构建密钥包含调试而不是发布)所以我添加

CONFIG += debug

到我的插件的项目文件中并像往常一样运行 qmake 和 mingw32-make 但这似乎没有效果。

我的插件项目文件现在是:

TEMPLATE = lib
CONFIG += plugin
QT -= gui
DESTDIR = lib

VERSION = 2.0.0

unix:include(conf.pri)
windows:CONFIG += crypto
windows:include(conf_win.pri)

CONFIG += create_prl

SOURCES = qca-ossl.cpp

windows:{
load(winlocal.prf)
isEmpty(WINLOCAL_PREFIX) {
error("WINLOCAL_PREFIX not found. See http://delta.affinix.com/platform/#winlocal")
}

OPENSSL_PREFIX = $$WINLOCAL_PREFIX
DEFINES += OSSL_097

INCLUDEPATH += $$OPENSSL_PREFIX/include
LIBS += -L$$OPENSSL_PREFIX/lib
LIBS += -llibeay32 -lssleay32
LIBS += -lgdi32 -lwsock32
}

!debug_and_release|build_pass {
CONFIG(debug, debug|release) {
mac:TARGET = $$member(TARGET, 0)_debug
windows:TARGET = $$member(TARGET, 0)d
}
}

CONFIG += debug

有人有任何想法吗?如果您需要更多详细信息,请询问,我已尽力尽可能详细。谢谢

汤姆

I have been trying to use QCA (Link) on my Windows PC for a couple of days now, works fine on my linux box, just can't get it working with Windows.

So i followed all the instructions for installing QCA and then the ossl plugin for QCA. The QCA works fine but for some reason the plugin isn't showing up in my Qt Creator nor am I able to use some of the functions in the plugin.

I used the qcatool2.exe that comes with QCA to check my plugins using

qcatool2 plugins --debug

and get this error message:

plugin: qca-ossl2.dll: failed to load: The plugin 'C:/Qt/2010.05/qt/plugins/crypto/qca-ossl2.dll' uses incompatible Qt library. Expected build key "Windows mingw debug full-config", got "Windows mingw release full-config"

Now this seems to me as if qt requires the plugin to be compiled in debug mode (as to get the build key to contain debug rather than release) so I added

CONFIG += debug

to my plugin's project file and ran qmake and mingw32-make as usual but this seems to have had no effect.

My project file for the plugin is now:

TEMPLATE = lib
CONFIG += plugin
QT -= gui
DESTDIR = lib

VERSION = 2.0.0

unix:include(conf.pri)
windows:CONFIG += crypto
windows:include(conf_win.pri)

CONFIG += create_prl

SOURCES = qca-ossl.cpp

windows:{
load(winlocal.prf)
isEmpty(WINLOCAL_PREFIX) {
error("WINLOCAL_PREFIX not found. See http://delta.affinix.com/platform/#winlocal")
}

OPENSSL_PREFIX = $WINLOCAL_PREFIX
DEFINES += OSSL_097

INCLUDEPATH += $OPENSSL_PREFIX/include
LIBS += -L$OPENSSL_PREFIX/lib
LIBS += -llibeay32 -lssleay32
LIBS += -lgdi32 -lwsock32
}

!debug_and_release|build_pass {
CONFIG(debug, debug|release) {
mac:TARGET = $member(TARGET, 0)_debug
windows:TARGET = $member(TARGET, 0)d
}
}

CONFIG += debug

Has anyone got any ideas? If you need anymore details just ask, I've tried to be as thorough as possible. Thanks

Tom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜夜流光相皎洁 2024-10-17 12:41:32

我一直在与类似的情况作斗争:qca-ossl 在 Linux 上构建得很好,但在 Windows 上根本不行。我刚刚取得了突破,这也可能对你有帮助。

版本和补丁

  • qtsdk-2010.05
  • qca-2.0.3
  • qca-ossl-r1190163(来自存储库)
  • openssl-1.0.0b

首先,如果您使用的是较新的版本(0.9.7+ ,我认为)对于 OpenSsl,您可能需要使用存储库中的 qca-ossl 版本,因为它修补了一些不兼容性。我还需要注释掉新的 qca-ossl.cpp 文件中处理 SHA224、SHA256、SHA384 和 SHA512 的一些行,以避免构建错误。我使用 qca-ossl 作为密码,所以我不担心散列,也没有太多调查错误。

修复它

Windows 构建问题对我来说有很多,但其中大多数源于 Windows 版本插件的劣质构建设置。为 Linux 端提供一些配置脚本很好,但是 Windows 端呢?我们需要做一些额外的工作。

其中一些额外工作是因为我为应用程序的支持库选择了非标准位置。 Qca 和 OpenSsl 都存在于项目目录结构中的libraries/目录中。我的猜测是,如果您尝试交叉编译应用程序,您已经做了类似的事情,但即使您没有这样做,以下内容也应该有所帮助。

寻找 OpenSsl

如果 Qca-ossl 找不到它应该连接到的库,它就不能很好地构建... :) 所以让我们直接指定它在哪里。注释掉与 winlocal.prf 相关的行以及 qca-ossl.pro 中由此产生的更改。我们将直接指定在哪里可以找到 openSsl。

TEMPLATE = lib
CONFIG += plugin
QT -= gui
DESTDIR = lib

VERSION = 2.0.0

unix:include(conf.pri)
windows:CONFIG += crypto
windows:include(conf_win.pri)

CONFIG += create_prl

SOURCES = qca-ossl.cpp

windows:{
# Rather than rely on the winlocal.prf file, we will specify the location of the openssl
# by hand when running qmake.
#
# load(winlocal.prf)
# isEmpty(WINLOCAL_PREFIX) {
# error("WINLOCAL_PREFIX not found. See http://delta.affinix.com/platform/#winlocal")
# }
#
# OPENSSL_PREFIX = $WINLOCAL_PREFIX
DEFINES += OSSL_097

INCLUDEPATH += $OPENSSL_PREFIX/include
LIBS += -L$OPENSSL_PREFIX/lib
LIBS += -llibeay32 -lssleay32
LIBS += -lgdi32 -lwsock32
}

!debug_and_release|build_pass {
CONFIG(debug, debug|release) {
mac:TARGET = $member(TARGET, 0)_debug
windows:TARGET = $member(TARGET, 0)d
}
}

现在我们可以直接访问 .pro 文件中的 $$OPENSSL_PREFIX 环境变量。我们可以在调用 qmake 时通过执行以下操作来设置它。

qmake.exe "OPENSSL_PREFIX=C:/path/to/openssl-1.0.0b"

您应该能够使用反斜杠或正斜杠。这里我选择forward,因为Qt从4.7开始就弃用了它们。

或者,您可以直接在 .pro 文件中设置 OPENSSL_PREFIX 变量。

寻找 Qca

在比较 qca-ossl 的 unix 和 windows makefile 后,奇怪的是,它从未包含用于构建或链接的 qca 库! ?!?!这导致 qca-ossl.cpp 末尾的 opensslPlugin 类定义的 Q_INTERFACES(QCAPlugin) 行出现“未定义接口”错误。

为了避免这种情况,我们需要手动显式定义包含路径和库路径。扩展上一节中的 qmake 行,最终的 qmake 行如下所示。

qmake.exe "OPENSSL_PREFIX=C:/path/to/openssl-1.0.0b" "INCLUDEPATH+=C:/path/to/qca-2.0.3/include/QtCrypto" "LIBS+=-LC:/path/to/qca-2.0.3/lib -lqca2"

“安装”Qca-ossl

运行上面的 qmake 行并运行普通的 ol' make 后,您需要安装 Qca-ossl。您可以将生成的 dll 从 lib/ 目录复制到 Qt 的插件目录,如果您使用我的版本,则该目录默认为 C:\Qt\2010.05\qt\plugins\crypto。或者,您可以将其移动到项目目录结构根级别的加密目录,例如 C:\path\to\my\project\crypto。

我希望这有帮助!

I've been struggling with a similar situation: qca-ossl builds fine on linux and not at all on windows. I just hit a breakthrough which might help you as well.

Versions and Patches

  • qtsdk-2010.05
  • qca-2.0.3
  • qca-ossl-r1190163 (from the repository)
  • openssl-1.0.0b

First of all, if you're using a newer version (0.9.7+, I think) of OpenSsl, you may need to use the qca-ossl version from the repository since it patches some incompatibilities. I also needed to comment out some lines in the new qca-ossl.cpp file dealing with SHA224, SHA256, SHA384, and SHA512 to avoid build errors. I'm using qca-ossl for the ciphers, so I'm not worried about hashing and didn't investigate the errors very much.

Fixing It

The windows build problems were many fold for me, but most of them stem from the shoddy build setup for the windows version of the plugin. It's nice having a little configure script for the linux side of things, but what about windows? We need to do a little extra work.

Some of this extra work is because I've chosen non-standard locations for the support libraries of my application. Qca and OpenSsl both exist within the project's directory structure in a libraries/ directory. My guess is that you've done something similar if you are trying to cross compile your application, but even if you didn't the following should help.

Finding OpenSsl

Qca-ossl wont build very well if it can't find the library it's supposed to connect to... :) So let's specify directly where it is. Comment out the lines relating to winlocal.prf and the changes that stem from it in qca-ossl.pro. We will directly specify where to find openSsl.

TEMPLATE = lib
CONFIG += plugin
QT -= gui
DESTDIR = lib

VERSION = 2.0.0

unix:include(conf.pri)
windows:CONFIG += crypto
windows:include(conf_win.pri)

CONFIG += create_prl

SOURCES = qca-ossl.cpp

windows:{
# Rather than rely on the winlocal.prf file, we will specify the location of the openssl
# by hand when running qmake.
#
# load(winlocal.prf)
# isEmpty(WINLOCAL_PREFIX) {
# error("WINLOCAL_PREFIX not found. See http://delta.affinix.com/platform/#winlocal")
# }
#
# OPENSSL_PREFIX = $WINLOCAL_PREFIX
DEFINES += OSSL_097

INCLUDEPATH += $OPENSSL_PREFIX/include
LIBS += -L$OPENSSL_PREFIX/lib
LIBS += -llibeay32 -lssleay32
LIBS += -lgdi32 -lwsock32
}

!debug_and_release|build_pass {
CONFIG(debug, debug|release) {
mac:TARGET = $member(TARGET, 0)_debug
windows:TARGET = $member(TARGET, 0)d
}
}

Now we have direct access to the $$OPENSSL_PREFIX environment variable in the .pro file. We can set it when we call qmake by doing the following.

qmake.exe "OPENSSL_PREFIX=C:/path/to/openssl-1.0.0b"

You should be able to use backward slashes or forward slashes. Here I choose forward since Qt has deprecated them since 4.7.

Alternatively, you could set the OPENSSL_PREFIX variable directly in the .pro file.

Finding Qca

After comparing the unix and windows makefiles for qca-ossl, oddly enough, it never includes the qca libraries for building or linking! ?!?! This led to an "Undefined interface" error on the Q_INTERFACES(QCAPlugin) line of the opensslPlugin class definition at the end of qca-ossl.cpp.

To avoid this, we will need to explicitly define the include and library paths by hand. Expanding on the qmake line from the last section the final qmake line is as follows.

qmake.exe "OPENSSL_PREFIX=C:/path/to/openssl-1.0.0b" "INCLUDEPATH+=C:/path/to/qca-2.0.3/include/QtCrypto" "LIBS+=-LC:/path/to/qca-2.0.3/lib -lqca2"

"Installing" Qca-ossl

After running the qmake line above and running a plain ol' make, you'll need to install Qca-ossl. You can copy the resulting dll from the lib/ directory to your Qt's plugins directory, which if you're using my versions defaults to C:\Qt\2010.05\qt\plugins\crypto. Alternatively, you can move it to a crypto directory that's at the root level of your project's directory structure such as C:\path\to\my\project\crypto.

I hope this helps!

放低过去 2024-10-17 12:41:32

实际上,您可以尝试本教程 Windows 上的 QCA+OpenSSL。运作良好。

顺便说一下,我可以在 Window 上使用带有 AES 256 的 QCA。但我不能在 Symbian 上使用它。有想法去做吗?

相关帖子

Actually, you can try this tutorial QCA+OpenSSL on Window. It's work well.

By the way, I can make use of QCA with AES 256 on Window. But i can't use it on Symbian. Any idea to do it?

Related Post

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文