Compiling Crypto++ in Microsoft Visual Studio 2019/2017 (with Cryptopp-PEM)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everybody i'm rasvi and in this video i'm gonna show you how you can make use of crypto plus plus the crypto library alongside its crypto pem module in microsoft visual studio 2019 and 17. the thing is i had to recently use visual studio for a project i'm involved in and it was my first time ever using it i of course had no idea how to create a project a solution how to compile it how to build it whatever and that's the main purpose of this video to save you the time i spent researching and finding out how to actually make it run without further ado let's get into it i'm going to use visual studio 2019 but as i just said it works just the same for 2017. the steps you're about to see they work just the same now for the sake of this example of this video i'm gonna create a new project right from scratch but of course if you want to reuse a project you already have or if you want to import your code just go ahead and fast forward the video skip to the next section i'm gonna create a console application and we have to give the project a name for example crypto pp once it finishes creating the project which apparently takes quite a while you will see a little main right here with its own hello world before continuing with our crypto plus plus example i must just go to tools options general and change the color theme to dark now we can get down to business okay much better now the next thing we need is some source code that actually makes use of crypto plus plus library i will copy this sample program of is right from crypto plus plus official wiki and i want to paste it in my main file okay i must save it and now as you can see it has no idea what these includes are or how to solve them what these classes and methods are and that's what we are about to solve in order to solve these problems the first thing we need is of course the library itself so let's find it in github we must download the source code from the official repository as you can see they have a release from march the 7th 2021 but i recommend you cloning the source code because there are changes updates that aren't included in the release so i want to clone it in my desktop if i manage to do so i have git for windows already installed and now i simply want to clone the code [Applause] once finished downloading the code you will see a new crypto pp folder here and now the next thing is downloading the crypto vm module for crypto plus plus if you don't have to use it i had just skip to the next section in order to download it we have to find out where the github repo of these files is let me see there you go as you can see there's a release from september 22nd 2019 more than two years ago and just as before i recommend you downloading or cloning the actual repo because obviously it is way more updated than the release we see here after cloning the repo you will see there's a new folder called crypto pm if you have to use it if you don't just skip to the next section of the video the next thing to do is copy the contents of this folder of pm straight into crypto pp folder because we will later need to compile all these files together just skip travis after copying the pm files into crypto pp folder the next thing is compiling the actual library in order to do so we have to look for a file called cryptlib.vcx proj that's a project file for visual studio i will open it in visual studio well 2019 at least that is my intention let me see if i manage to do so okay opening it in visual studio 2019 now by the way i just noticed that in visual studio 2017 you will find the solution explorer the contextual menu on the left side of your screen but it doesn't matter the steps remain just the same when you open the cryptlib project you will find four different solutions each of these solution is different from the other of course and depending on your needs you may want to build one or another if you want to find more info about what each one of those is i recommend you reading the official documentation of the crypto pp wiki uh of their visual studio project this link and any other link i'm using in the video i will leave them right below in the description here you can find out what each one of these solution is in my case i want to compile cryptlib before doing so as i'm using crypto pm i have to add the headers and source files in their respective folder even though we copied them in the folder of crypto pp you have to add it via the graphical interface if you drag them with your mouse right from the explorer of windows it doesn't seem to work i had problems with it i don't know why so in order to do so right click on header files add existing item and select those header files related to pm in this case they are pm.h and pm common now we have to do just the same with source files right click on source file folder add existing item and we have to add the source files that cpp files related to pm in this case they are pm common pm read and pm write there is also a certifications file but in my case i didn't have to use it we click on add now the files are added to our solution and in order to build it we have to first select the solution configuration that better suits our needs in my case it was release for 64 bits after selecting those right click on the solution and click build this process may take a while after it finishes building you should see one succeeded if you find any errors or warnings while building the project which by the way you shouldn't if you followed my steps i recommend you taking a look at the closed issue of the crypto ppm github repository where we discussed some errors with microsoft visual studio if you clone the updated version it shouldn't happen anymore now if you take a look at the folder of our crypto pp project library you will notice there is a x64 folder and inside it you will find cryptlib and output in the output release folder directory you will find the actual library this library we will have to use in our visual studio configuration for the project of crypto plus plus in order to make it run now let's go back to our project we can close this window and recover our crypto pp project now in order to make it run and get rid of these errors and solve this includes we have to configure our project in order to do so right click on our crypto bp solution and select properties and in the properties menu we have several things to change or to include rather before changing the configuration make sure you are changing the actual solution configuration you are about to build your project with if you change any other when you click compile or build it won't apply for the sake of this example i will change all configurations for all platforms at once but i don't recommend you doing so just modify the configurations that you actually need now the first thing we want to change is from the c c plus plus drop down menu we have a general option and in the field called additional include directories we have to specify our directory for the crypto pp as well as pm folder where the cpp and headers files are i recommend you editing it the way you're supposed to do so okay now the next property to modify we find it in the general option in the linker drop down menu and it is the field called additional library directories we have to include the directory of our recently compiled library now we must edit it and let me just copy the folder that's the folder the cryptopp x64 output release and we only need this path because it asks for a directory the next thing to modify is in the input option here we have to specify in the additional dependencies field the name of the library or libraries we additionally want to use in my case it's just craftly cryptlib sorry that lib okay and last but not least in order to get it running we must modify in the once again c dash c plus plus menu uh in code generation options there is a field called runtime library we have to modify it and select multi-threaded now we apply our changes we click ok and if everything went well and there aren't any last moment surprises we can see that now we got rid of our of the errors and visual studio is actually able to solve these includes nice that's nice but of course the final test is running the code and checking verifying it is running as expected i will change this plain text text string in order to make sure it's running my code [Applause] okay well never mind just a little typo crypto pp and rise builder flow is recording okay now we save it and before running make sure that you selected the configuration solution just the same exactly the same that you compiled the crypto pp library with that is if you compiled crypto pp in release and x64 as it was my case now you have to use the code in that very same configuration if you compiled if you build it with i don't know debug for uh 86 you have to choose the bug and 86 right here let's see if it actually runs ok finish generating code and plain text raspberry overflow is recording some crypto pb videos the key and the recover text and everything seems to work just fine and that's how i got crypto plus plus running in microsoft visual studio if there's anything you have to say leave a comment below and i really hope you found this video helpful i hope it helps that's all for today see you in the next one
Info
Channel: RazviOverflow
Views: 1,234
Rating: undefined out of 5
Keywords: microsoft visual studio, c++, crypto++, cryptopp
Id: 5XE4zEN-WKg
Channel Id: undefined
Length: 13min 47sec (827 seconds)
Published: Sat Sep 25 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.