Crypto ++无法构建Qt应用程序 [英] Crypto++ can't build Qt Application
问题描述
我目前正在尝试在我的Qt应用程序中运行Crypto ++.但这是行不通的.希望你们中的某人知道出了什么问题,因为我还没有弄清楚,现在已经有3天了.
I am currently trying to run Crypto++ in my Qt Application. But it does not work. Hopefully somebody of you knows whats wrong, because I have not figured it out and I am on this for 3 days now.
为了解决这个问题,我创建了一个测试应用程序.保留此代码: http://pastebin.com/1XMARtds 取自
To concentrate the problem, I have created a test app. Holding this code: http://pastebin.com/1XMARtds taken from http://programmingknowledgeblog.blogspot.de/2013/04/compiling-and-integrating-crypto-into.html
我的.pro像这样:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../Savor_V100/libraries/ -lcryptlib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../Savor_V100/libraries/ -lcryptlibd
else:unix: LIBS += -L$$PWD/../Savor_V100/libraries/ -lcryptlib
INCLUDEPATH += $$PWD/../Savor_V100/includes/cryptopp562
DEPENDPATH += $$PWD/../Savor_V100/includes/cryptopp562
我已使用MS Visual Studio 2012编译了该库. 当我使用以下设置时: http://i.imgur.com/Nd9TEIA.png
I have compiled the library with MS Visual Studio 2012. When I use these settings: http://i.imgur.com/Nd9TEIA.png
我得到一个50mb-ish的.lib文件.
I get a single 50mb-ish .lib file.
当我然后尝试在Qt Creator(5.0.2)中构建应用程序时,得到以下信息: http://i.imgur.com/RbCGQDU.png
When I then try to build my application in Qt Creator (5.0.2) I get the following: http://i.imgur.com/RbCGQDU.png
很多:
cryptlib.lib(cryptlib.obj):-1: error: LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in main.obj
它还说:找不到文件:cryptlib.lib(cryptlib.obj)
It also says: File not found: cryptlib.lib(cryptlib.obj)
如果将.obj文件与.lib文件放在同一文件夹中,那么我会摆脱找不到文件"错误.但是没有其他改变.
If I put the .obj files in the same folder as the .lib file I get rid of the "file not found" errors. But nothing else changes.
有人可以解释我做错了什么吗?网站上的LNK2038信息对我没有帮助:(
Could somebody please explain what I am doing wrong ? The LNK2038 info on the website does not help me:(
推荐答案
Step 7 of the instructions you linked to here appear to be strange. Normally you'd select /MD
and /MDd
for Release and Debug respectively, or you'd select /MT
and /MTd
.
问题的关键在于,您将加密的Release版本链接到C运行时库的动态版本(通过/MD
),但是将测试exe设置为链接到静态版本(通过/MT
).
The crux is that you have your Release build of crypto linked to the Dynamic version of the C Runtime Library (via /MD
), but your test exe is set to link to the Static version (via /MT
).
您应该只链接到CRT的单个版本-即在释放模式下设置/MT
而不是/MD
来重新编译crypto ++,或者将测试exe更改为使用/MD
.
You should only link to a single version of the CRT - i.e. recompile crypto++ in Release mode with /MT
set instead of /MD
, or change your test exe to use /MD
.
有关这些标志的更多信息,请参见 msdn文档.
For further info on these flags, see the msdn docs.
这篇关于Crypto ++无法构建Qt应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!