I am need to calculate SHA3 in my program as well as use AES in my sockets and have decided to use crypto++ library.
I am new to Visual Studio environment with no prior experience on visual studios but have extensively worked on g++ (linux/mingw-w64). One of the third part library I am using recommends Visual Studios (causes linker error when used with g++).
I am getting an linker error. Error :
LNK2001 unresolved external symbol "public: virtual void __cdecl CryptoPP::SHA3::Update(unsigned char const *,unsigned __int64)" (?Update@SHA3@CryptoPP@@UEAAXPEBE_K@Z) ConsoleApplication2 C:\Users\Admin\source\repos\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.obj 1
LNK2019 unresolved external symbol "public: virtual void __cdecl CryptoPP::SHA3::Restart(void)" (?Restart@SHA3@CryptoPP@@UEAAXXZ) referenced in function "public: __cdecl CryptoPP::SHA3::SHA3(unsigned int)" (??0SHA3@CryptoPP@@QEAA@I@Z) ConsoleApplication2 C:\Users\Admin\source\repos\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.obj 1
Error LNK2001 unresolved external symbol "public: virtual void __cdecl CryptoPP::SHA3::TruncatedFinal(unsigned char *,unsigned __int64)" (?TruncatedFinal@SHA3@CryptoPP@@UEAAXPEAE_K@Z) ConsoleApplication2 C:\Users\Admin\source\repos\ConsoleApplication2\ConsoleApplication2\ConsoleApplication2.obj 1
The same code works properly in g++(mingw-w64 - I am using dll created in mingw-w64)
OS : Windows 10 Pro 64 bit
Development Environment : Visual Studios 2017
Target : Debug x64
Source :
#include <sha3.h>
#include <filters.h>
#include <hex.h>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iostream>
#include <base64.h>
int main()
{
CryptoPP::SHA3_512 hash;
std::cout << hash.AlgorithmName() << " Test." << std::endl;
std::string in = "The quick brown fox jumps over the lazy dog";
std::vector<CryptoPP::byte> out(hash.DigestSize());
hash.CalculateTruncatedDigest(&out[0], hash.DigestSize(), reinterpret_cast<CryptoPP::byte*>(&in[0]), in.size());
std::cout << in << std::endl;
std::cout.setf(std::ios::hex, std::ios::basefield);
for_each(out.begin(), out.end(), [](CryptoPP::byte i) {
printf("%x", i);
});
std::cout << "Original String : " << str << std::endl;
return 0;
}
Kindly advice me how to load (copy) all generated dll in some common folder just like the make install command (facility) in gcc.
Edit :
I have added cryptopp.lib in additional dependencies and added the folder containing both cryptopp.lib and cryptopp.dll in Additional Library Directory. I have added the directory in Path environment variable. I have selected Multi Threaded Debug Dll in Debug x64 configuration during dll generation in cryptolib project.