c++ - How to add Crypto++ library to Qt project -
i downloaded crypto++ source , compiled cryptlib project in visual studio 2013, , added generated .lib file qt project, made .pro file 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 library project, build , following error:
:-1: error: no rule make target 'c:/users/special services/workorder/libcryptlibd.a', needed 'debug\untitled.exe'. stop.
i believe understand error telling me need additional line of else:win32
lines under dependpath
... or because lines added use $$pwd
, isn't unix command? i've looked around @ other instances of error , i'm problem in .pro file here.
edit:
i decided take different approach. got rid of importing library added .pro file, , instead put line of code in place:
win32:libs += c:\qt\5.2.1\mingw48_32\include\cryptopp\win32\output\debug\cryptlib.lib
(the path cryptlib.lib file)
this built fine. made sure of cryptopp header files in include directory, c:\qt\5.2.1\mingw48_32\include\cryptopp
i tried include file, #include <cryptopp/aes.h>
, built fine. first time built, there 40+ warnings, second time built, built without any.
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, name of crypto++ library cryptlib.lib
, not libcryptlib.a
. if used cygwin (which don't believe did), name would libcryptopp.a
.
the libcryptlibd.a
(notice addition of d
) not correct. stands 'debug', , used years ago in visual studio 5.0/6.0 days. based on compiling , integrating crypto++ microsoft visual c++ environment. if renamed win32/debug/cryptlib.lib
win32/debug/cryptlibd.lib
, ok if paths ok.
i think recommended way of doing things use cryptlib.lib
library (same name everywhere), , change linker paths based on configuration. paths be:
- win32, debug:
<crypto++ dir>/win32/debug/
- win64, debug:
<crypto++ dir>/x64/debug/
- win32, release:
<crypto++ dir>/win32/release/
- win64, release:
<crypto++ dir>/x64/release/
here's screen capture of adding cryptlib.lib
under visual studio. notice applies configurations:
and here's how change linker paths visual studio finds proper cryptlib.lib
:
in above, cryptopp_lib32
environmental variable value c:\users\special services\crypto++\win32\
. similarly, cryptopp_lib64
c:\users\special services\crypto++\x64\
unfortunately, don't know how these things under qtcreator.
Comments
Post a Comment