I have built cryptopp statically on my system it passes all tests too. These are the warning though I get during tests
WARNING: CRYPTOPP_NO_UNALIGNED_DATA_ACCESS is not defined in config.h.
WARNING: CRYPTOPP_INIT_PRIORITY is not defined in config.h.
WARNING: CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 is defined in config.h.
WARNING: You should make these changes in config.h, and not CXXFLAGS.
WARNING: You can 'mv config.recommend config.h', but it breaks versioning.
WARNING: See http://cryptopp.com/wiki/config.h for more details.
I now link this in my QT project file as
TEMPLATE = app
LIBS += -L/usr/lib/libcryptopp.a
#LIBS += -lcryptopp
CONFIG += console c++11
CONFIG += staticlib
SOURCES += main.cpp \
hashdata.cpp
HEADERS += \
hashdata.hpp
But when I compile this I get all undefined errors.
hashdata.o: In function `hashdata::hashfunction(std::string)':
hashdata.cpp:(.text+0x1fb): undefined reference to `CryptoPP::Algorithm::Algorithm(bool)'
hashdata.cpp:(.text+0x270): undefined reference to `CryptoPP::SHA512::InitState(unsigned long long*)'
hashdata.cpp:(.text+0x29a): undefined reference to `CryptoPP::Algorithm::Algorithm(bool)'
hashdata.cpp:(.text+0x2a1): undefined reference to `vtable for CryptoPP::StringSinkTemplate<std::string>'
hashdata.cpp:(.text+0x30b): undefined reference to `CryptoPP::Filter::Filter(CryptoPP::BufferedTransformation*)'
hashdata.cpp:(.text+0x312): undefined reference to `vtable for CryptoPP::Grouper'
hashdata.cpp:(.text+0x35e): undefined reference to `CryptoPP::Filter::Detach(CryptoPP::BufferedTransformation*)'
hashdata.cpp:(.text+0x375): undefined reference to `CryptoPP::Filter::Filter(CryptoPP::BufferedTransformation*)'
hashdata.cpp:(.text+0x37c): undefined reference to `vtable for CryptoPP::BaseN_Encoder'
hashdata.cpp:(.text+0x3d3): undefined reference to `CryptoPP::Filter::Detach(CryptoPP::BufferedTransformation*)'
hashdata.cpp:(.text+0x3e5): undefined reference to `CryptoPP::ProxyFilter::ProxyFilter(CryptoPP::BufferedTransformation*, unsigned long, unsigned long, CryptoPP::BufferedTransformation*)'
hashdata.cpp:(.text+0x3ec): undefined reference to `vtable for CryptoPP::HexEncoder'
hashdata.cpp:(.text+0x452): undefined reference to `vtable for CryptoPP::AlgorithmParametersTemplate<int>'
hashdata.cpp:(.text+0x4af): undefined reference to `vtable for CryptoPP::AlgorithmParametersTemplate<CryptoPP::ConstByteArrayParameter>'
...
I have seen a similar problem previously when I searched in google, but the solution isn't clear. Could it be because of C++11 flags ?
I can comment on this warning. You should perform the steps it says:
config.recommend
puts the library is a better configuration by completely avoiding known undefined behavior that could not be removed without breaking versioning. Since you don't appear to have versioning issues (like say, Fedora or Debian), then you can perform the move.When you build Crypto++, you should use the same compiler and flags for the library and app. I suggest the following.
Crypto++:
Qt App
Also see GNUmakefile | Building the Library on the Crypto++ wiki.
These are coming from source (
*.cpp
) files. I'm guessing (and its purely a guess) one of two problems:libcryptopp.a
Use
nm
to inspect the symbols. Something like the following (the ' T " tells you its defined and in the text section):If the symbols are present by QT Creator is not finding the Crypto++ library, then see something like Adding external library into Qt Creator project.
From Comments:
An archive, like
libcryptopp.a
, is a collection of object files. You add it toOBJECTS
, notLIBS
, so you want something like:You use
-L
to specify a library path to a linker. It does not make much sense to-L/usr/lib/libcryptopp.a
since its used for paths.On Linux, you can force static linking by either (1)
-Bstatic -lcryptopp
; or (2) directly specifying/usr/lib/libcryptopp.a
. The Crypto++ test program uses method (2):On OS X, the linker always links to the dynamic object. It even does so on iOS, where userland is usually not allowed to load dynamic objects. To avoid dynamic linking, either (1) move or rename the
*.dylib
; or (2) directly specifying/usr/lib/libcryptopp.a
. The Crypto++ test program uses method (2):