Reputation: 998
I downloaded the Crypto++ source and compiled the cryptlib project in Visual Studio 2013, and then I added the generated .lib file to my Qt project, which made my .pro file look like this:
QT += core gui
QT += sql
greaterThan(QT_MAJOR_VERSION, 4):QT += widgets
TARGET = untitled
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h \
databasecontrol.h \
test.h
FORMS += mainwindow.ui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/ -lcryptlib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/ -lcryptlibd
else:unix: LIBS += -L$$PWD/ -lcryptlib
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/libcryptlib.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/libcryptlibd.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/cryptlib.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/cryptlibd.lib
else:unix: PRE_TARGETDEPS += $$PWD/libcryptlib.a
Immediately after adding this library to the project, I build it and get the following error:
:-1: error: No rule to make target 'C:/Users/Special Services/WorkOrder/libcryptlibd.a', needed by 'debug\untitled.exe'. Stop.
I believe I understand that the error is telling me that I need an additional line where all of the else:win32
lines are under DEPENDPATH
... or is it because the lines that were added use $$PWD
, isn't that a Unix command? I've looked around at other instances of this error and I'm fairly certain the problem is with something in the .pro file here.
EDIT:
I decided to take a different approach. I got rid of anything that importing a library added to my .pro file, and instead just put this line of code in its place:
win32:LIBS += C:\Qt\5.2.1\mingw48_32\include\cryptopp\Win32\Output\Debug\cryptlib.lib
(The path to the cryptlib.lib file)
This built just fine. I made sure that all of the cryptopp header files were in my include directory, C:\Qt\5.2.1\mingw48_32\include\cryptopp
I then tried to include a file, with #include <cryptopp/aes.h>
and it built fine. The first time I built, there were 40+ warnings, but the second time I built, it built without any.
Upvotes: 4
Views: 5037
Reputation: 102245
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/libcryptlib.a else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/libcryptlibd.a
On Windows under Visual Studio, the name of the Crypto++ library is cryptlib.lib
, not libcryptlib.a
. If you used Cygwin (which I don't believe you did), then the name would be libcryptopp.a
.
The libcryptlibd.a
(notice the addition of the d
) is probably not correct. It stands for 'debug', and its something that was used years ago in the Visual Studio 5.0/6.0 days. It was based on Compiling and Integrating Crypto++ into the Microsoft Visual C++ Environment. If you renamed Win32/Debug/cryptlib.lib
to Win32/Debug/cryptlibd.lib
, then you are probably OK if your paths are OK.
I think the recommended way of doing things now is to use cryptlib.lib
as the library (same name everywhere), and change the linker paths based on the configuration. The paths would be:
<crypto++ dir>/Win32/Debug/
<crypto++ dir>/x64/Debug/
<crypto++ dir>/Win32/Release/
<crypto++ dir>/x64/Release/
Here's a screen capture of adding cryptlib.lib
under Visual Studio. Notice it applies to all configurations:
And here's how to change the linker paths so Visual Studio finds the proper cryptlib.lib
:
In the above, CRYPTOPP_LIB32
would be an environmental variable with a value like C:\Users\Special Services\Crypto++\Win32\
. Similarly, CRYPTOPP_LIB64
would be C:\Users\Special Services\Crypto++\x64\
Unfortunately, I don't know how to do these things under QtCreator.
Upvotes: 1