'crypto++ library integration with omnet++

I was trying to build cryptopp library with clang (as some one told me in a previous question)
I did as mentioned here: https://www.cryptopp.com/wiki/GNUmakefile
I used CXX=clang++ make in the library folder, But:

  • In linux (ubunto), I was able to build the library successfully with clang and could include it in an omnet++ project, used it, and the project was built successfully. It worked fine.
  • In Windows 10, I could build the library also with clang. But when I include it to a project in omnet++ and build, I get this error:
    The build log is here:
16:08:12 **** Build of configuration release for project crypto_final ****
make MODE=debug all 
cd src && /usr/bin/make
make[1]: Entering directory '/d/omnetpp-5.7/samples/crypto_final/src'
Client.cc
Server.cc
Creating executable: ../out/clang-debug/src/crypto_final_dbg.exe
lld-link: error: undefined symbol: CryptoPP::StringSinkTemplate<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::StringSinkTemplate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
>>> referenced by Client.cc:63
>>>               ../out/clang-debug/src/Client.o:(Client::handleMessage(omnetpp::cMessage*))
>>> referenced by Client.cc:95
>>>               ../out/clang-debug/src/Client.o:(Client::handleMessage(omnetpp::cMessage*))

lld-link: error: undefined symbol: CryptoPP::StringStore::TransferTo2(CryptoPP::BufferedTransformation&, unsigned long long&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)
>>> referenced by D:/omnetpp-5.7/tools/cryptopp3/filters.h:1440
>>>               ../out/clang-debug/src/Client.o:(CryptoPP::SourceTemplate<CryptoPP::StringStore>::Pump2(unsigned long long&, bool))

lld-link: error: undefined symbol: CryptoPP::BufferedTransformation::TransferMessagesTo2(CryptoPP::BufferedTransformation&, unsigned int&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)
>>> referenced by D:/omnetpp-5.7/tools/cryptopp3/filters.h:1442
>>>               ../out/clang-debug/src/Client.o:(CryptoPP::SourceTemplate<CryptoPP::StringStore>::PumpMessages2(unsigned int&, bool))

lld-link: error: undefined symbol: CryptoPP::BufferedTransformation::TransferAllTo2(CryptoPP::BufferedTransformation&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)
>>> referenced by D:/omnetpp-5.7/tools/cryptopp3/filters.h:1444
>>>               ../out/clang-debug/src/Client.o:(CryptoPP::SourceTemplate<CryptoPP::StringStore>::PumpAll2(bool))

lld-link: error: undefined symbol: CryptoPP::RandomPool::GenerateIntoBufferedTransformation(CryptoPP::BufferedTransformation&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long long)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::AutoSeededRandomPool)

lld-link: error: undefined symbol: CryptoPP::BufferedTransformation::ChannelCreatePutSpace(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long long&)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Sink)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Bufferless<CryptoPP::Filter>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Unflushable<CryptoPP::Filter>)
>>> referenced 6 more times

lld-link: error: undefined symbol: CryptoPP::BufferedTransformation::ChannelPut2(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char const*, unsigned long long, int, bool)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Sink)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Bufferless<CryptoPP::Filter>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Unflushable<CryptoPP::Filter>)
>>> referenced 1 more times

lld-link: error: undefined symbol: CryptoPP::BufferedTransformation::ChannelPutModifiable2(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*, unsigned long long, int, bool)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Sink)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Bufferless<CryptoPP::Filter>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Unflushable<CryptoPP::Filter>)
>>> referenced 6 more times

lld-link: error: undefined symbol: CryptoPP::BufferedTransformation::ChannelFlush(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, int, bool)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Sink)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Bufferless<CryptoPP::Filter>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::SimpleProxyFilter)
>>> referenced 5 more times

lld-link: error: undefined symbol: CryptoPP::BufferedTransformation::ChannelMessageSeriesEnd(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, bool)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Sink)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Bufferless<CryptoPP::Filter>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Unflushable<CryptoPP::Filter>)
>>> referenced 1 more times

lld-link: error: undefined symbol: CryptoPP::BufferedTransformation::SetRetrievalChannel(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Sink)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Bufferless<CryptoPP::Filter>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Unflushable<CryptoPP::Filter>)
>>> referenced 6 more times

lld-link: error: undefined symbol: CryptoPP::Filter::TransferTo2(CryptoPP::BufferedTransformation&, unsigned long long&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Bufferless<CryptoPP::Filter>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Unflushable<CryptoPP::Filter>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::SimpleProxyFilter)
>>> referenced 3 more times

lld-link: error: undefined symbol: CryptoPP::Filter::CopyRangeTo2(CryptoPP::BufferedTransformation&, unsigned long long&, unsigned long long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) const
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Bufferless<CryptoPP::Filter>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::Unflushable<CryptoPP::Filter>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::SimpleProxyFilter)
>>> referenced 3 more times

lld-link: error: undefined symbol: CryptoPP::Rijndael::Base::AlgorithmProvider[abi:cxx11]() const
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec>)
>>> referenced 1 more times

lld-link: error: undefined symbol: non-virtual thunk to CryptoPP::Rijndael::Base::AlgorithmProvider[abi:cxx11]() const
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::ClonableImpl<CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)0, CryptoPP::Rijndael::Enc>, CryptoPP::Rijndael::Enc>)
>>> referenced by ../out/clang-debug/src/Client.o:(vtable for CryptoPP::BlockCipherFinal<(CryptoPP::CipherDir)1, CryptoPP::Rijndael::Dec>)
>>> referenced 1 more times

lld-link: error: undefined symbol: CryptoPP::DEFAULT_CHANNEL[abi:cxx11]
>>> referenced by ../out/clang-debug/src/Client.o:(.refptr._ZN8CryptoPP15DEFAULT_CHANNELB5cxx11E)

lld-link: error: undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
>>> referenced by ./cryptlib.h:183
>>>               libcryptopp.a(cryptlib.o):(CryptoPP::SelfTestFailure::SelfTestFailure(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&))
>>> referenced by ./cryptlib.h:183
>>>               libcryptopp.a(cryptlib.o):(CryptoPP::InvalidKeyLength::InvalidKeyLength(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long))
>>> referenced by ./cryptlib.h:183
>>>               libcryptopp.a(cryptlib.o):(CryptoPP::InvalidArgument::InvalidArgument(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&))
>>> referenced 161 more times

lld-link: error: undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*, unsigned long long)
>>> referenced by C:/llvm/include/c++/v1/string:4227
>>>               libcryptopp.a(cryptlib.o):(CryptoPP::InvalidKeyLength::InvalidKeyLength(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long))
>>> referenced by C:/llvm/include/c++/v1/string:2684
>>>               libcryptopp.a(cryptlib.o):(CryptoPP::InvalidKeyLength::InvalidKeyLength(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long))
>>> referenced by C:/llvm/include/c++/v1/string:2684
>>>               libcryptopp.a(cryptlib.o):(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&))
>>> referenced 44 more times

lld-link: error: undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*)
>>> referenced by C:/llvm/include/c++/v1/string:4290
>>>               libcryptopp.a(cryptlib.o):(CryptoPP::SimpleKeyingInterface::ThrowIfResynchronizable())
>>> referenced by C:/llvm/include/c++/v1/string:4290
>>>               libcryptopp.a(cryptlib.o):(CryptoPP::SimpleKeyingInterface::ThrowIfInvalidIV(unsigned char const*))
>>> referenced by C:/llvm/include/c++/v1/string:4290
>>>               libcryptopp.a(cryptlib.o):(CryptoPP::SimpleKeyingInterface::ThrowIfInvalidIVLength(int))
>>> referenced 463 more times

lld-link: error: undefined symbol: std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > std::__1::operator+<char, std::__1::char_traits<char>, std::__1::allocator<char> >(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
>>> referenced by ./misc.h:749
>>>               libcryptopp.a(cryptlib.o):(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > CryptoPP::IntToString<int>(int, unsigned int))
>>> referenced by ./cryptlib.h:337
>>>               libcryptopp.a(integer.o):(CryptoPP::NameValuePairs::ValueTypeMismatch::ValueTypeMismatch(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::type_info const&, std::type_info const&))
>>> referenced by libcryptopp.a(algparam.o)
>>> referenced 9 more times

lld-link: error: too many errors emitted, stopping now (use /errorlimit:0 to see all errors)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:99: ../out/clang-debug/src/crypto_final_dbg.exe] Error 1
make[1]: Leaving directory '/d/omnetpp-5.7/samples/crypto_final/src'
make: *** [Makefile:2: all] Error 2
"make MODE=debug all" terminated with exit code 2. Build might be incomplete.

16:08:23 Build Failed. 2 errors, 0 warnings. (took 11s.560ms)
  • In both cases (Linux and Windows), I added two link options in makemake for the library:
    -lcryptopp
    -lpthread

I want it to work fine in windows because all my work is on windows, and I only have linux on a virtual machine...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source