This repository will document my C++ learning journey. It will also serve as document to look back and see how far I have come.
You can find source code of repository i'm working on here sk-cpp-research.
Download and build library, make sure you know where .dll will be.
- Build Crypto++ library
- Building instructions for Crypto++ were inside zip file I downloaded
- After downloading zip file, there was Install.txt file with instructions. Because I never worked with C++ libraries, I didn't know how to follow them.
- After few hours of research about things mentioned in file, I realized i need to run commands for installing... and that is it. Commands were:
makemake testmake install(because i am on windows)
- The issue with running
makecommand is, I don't have it, but I have MinGW installed with MSYS2. - Turns out MSYS2 will install
g++,makeafter following this guide MSYS2 Getting Started. - This allowed me to run commands required in Install.txt and this step wasn't obstacle any more.
- Linking Crypto++ library
- I needed library code in project to be able to import header files.
- After adding code to test if I can use the library, I was getting error that reference to CryptoPP namespace is undefined.
- Linking failed...
- After following instructions for adding static library to CLion i learned that linking failed because
.dllwasn't found. - After search I found out that CMake can't find
.dllso I searched where isusr/localon my machine and found this. - After going to
%windir%\system32i foundlibcryptopp.dll. - After that I just copied it to CLion project and linked it as instructions ordered, then code worked.
After building library and linking it in CLion, i used the following code to verify that it works.
#include "cryptlib.h"
#include "sha.h"
#include <iostream>
int main (int argc, char* argv[])
{
using namespace CryptoPP;
SHA256 hash;
std::cout << "Name: " << hash.AlgorithmName() << std::endl;
std::cout << "Digest size: " << hash.DigestSize() << std::endl;
std::cout << "Block size: " << hash.BlockSize() << std::endl;
return 0;
}After understanding how libraries work in C++ I realized I made a mistake, the steps I had to do were as follows:
Prerequisites needed for me were to have:
- Make
I learned that to run make command i had to do it from MSYS2 MiNGW shell.
- Download library source code
- Place library source code to my project
- Open shell, enter library directory, follow install instructions
- Link
*.aoutput of library in CMake - Because I use CLion - Now I can use library
The chaos from yesterday is gone. Setting up library and cleaning up mess from yesterday was quick.
Before figuring out how to add c++ library on my own, I asked a friend.
A few days later I talked to him about my experience, how I realized that first I need to build a library, then link it. Also I told him it would be problem if I had 10 libraries, because I would need to build each of them individually.
He mentioned package manager can help with that, but that package managers are often configured on company or project level.
Another thing he mentioned was, CMake is pretty much standard and he was surprised this library didn't support CMake.
I have to learn about this, but later.