How to include Crypto++ into a VS Project - c++

I'm working on a Project that utilizes CryptoPP, but I always get Linking Issues when I try to Compile my Code. Now I wanted to ask here If someone knows howto Link it Correctly.
I already tried:
Downloading Crypto++
Opening the SLN
Building cryptlib
Moving the cryptlib.lib to my project folder
Including the Crypto++ header into my project
Adding the cryptlib.lib to the header files.
I expect my project to fully compile and link, without errors and being able to run some AES just for testing.

The best way is to create a folder named cryptopp inside your project folder (where the .SLN is located) clone or download the source from cryptopp inside the directory.
From [Visual Studio->Solution Explorer] click on [Solution->Add->Existing Project] and select the cryptlib.vcproj file to include in your solution.
You can find an example of a project using cryptopp here https://github.com/mrc-g/BitMRC

Related

Visual Studio C++ how to add header files in a prefix folder

I cloned a github C++ repository. The repository is not a VS project. So I manually created a VS C++ blank project and added the files from the repo to the project. The files are not copied. This is not the problem.
The repo directory looks like this:
include\NTL\*.h
src\*.cpp
*.h means a bunch of header files and *.cpp means a bunch of .cpp source files.
The problem is that the .cpp files have #include <NTL/*.h> and when I build, VS fails to locate the header files (No such file or directory). Adding the path to the include to the Include Directories in project properties didn't help.
EDIT: After some experimenting, I've found that the error has nothing to do with the prefix NTL in #include <NTL/*.h> but with whether the files are copied into project directory. Even though the files appear in VS project view, they must be copied into the project directory.
EDIT: The only way I've managed to get the project to compile is to put the whole NTL directory containing header files in project directory. Include Directories and Additional Include Directories in project properties don't seem to have any effect.
All previous No such file or directory errors were the result of some combination of:
Mismatching project properties Configuration and Platform
Some .h files were actually missing from NTL github repo, e.g. mach_desc.h.
The solution to the problem consists of the following:
Under project Properties > C/C++, add the path to the include to Additional Include Directories.
VS project has a separate set of properties for each combination of Configuration and Platform. Make sure that step 1 applies to the active Configuration and Platform. E.g. If the project's currently configured to build for Debug x64 (active Configuration:Debug and Platform:x64), make sure that step 1 applies to Debug x64, and not something like Release Win32 or Release x64, etc.
Use the Windows/Linux-specific zip package from the Downloads page of the official website https://libntl.org/download.html

How to include a library in my code using cmake?

I have tried to ´make´ the library yaml-cpp, not sure I did it right, but how do I build it?
In the tutorial (https://github.com/jbeder/yaml-cpp/blob/master/README.md) it says to run cmake in the build dir, but cmake could not find the cmakelist file, so I did it in the source dir, but then what? How do I build it?
If someone could make a newbie step by step to get the library (or any library really) so I can include it in my code, that would be awesome.
Im using Windows 7, and compiling using terminal (using Codeblocks MinGW gcc/g++) and sublime text 3 editor.
Edit: I have not "make". How can I get this?
Here is the step by step guide:
For the purpose of this answer I will use cmake gui instead to highlight a few key points.
go to https://github.com/jbeder/yaml-cpp and download the root library.
open cmake gui and select the source directory as <my project>/yaml-cpp-master
select a directory for the build. I would call it <my project>/yaml-cpp-master/codeblocks_build
press configure and then check all the values.
press generate and wait for it to complete.
Find the generated codeblocks project file within <my project>/yaml-cpp-master/codeblocks_build
Compile the project as you normally would.
find the generated DLL files and link them to your project.
The reason why you are getting this error is because cmake is trying to find the source code in the directory build which is newly created as seen in the tutorial:
mkdir build
cd build
This is meant to specify to cmake where to build it in rather than where to build from. If you wish to use it via a command line you will need to tell cmake where to build and where the source is.
To then call the functions from that library you will need to link the header files (files that start with .h or .hpp) and the DLL libraries.
the .cpp .c etc is where the implementation is but .h .hpp is where the definitions are.
So when you are including like this: #include<something.h> you are including definitions which are later filled by the .cpp files however in case of a library they are instead filled from .dll or .o

CMake Xcode using wrong files in Issue Navigator

I generate an Xcode project from CMake that builds a static library and test executable.
After the library is built, there is a file copy operation that moves the headers to a central directory (an include folder next to the built library).
This directory is not listed in the header search paths for either project (I have verified this inside the Xcode project and CMakeLists files).
When I am working in the generated Xcode project, the Issue Navigator will open the files in the central directory instead of the files used to build the project.
Can anyone tell me why this happens and how I can fix it?
Thanks for your help.
Use a separate build directory. Create a new directory. Navigate to that in terminal and say :
cmake -G Xcode <path_to_source>

VS2012: Program can't start because "libvorbisfile.dll" is missing

I've got a project and I'm trying to make it read a .OGG file.
I've downloaded the libogg and libvorbis from here, compiled them (had some trouble figuring I had to build libogg first), then got the following files:
libogg.lib
libogg.dll
libvorbis.lib
libvorbis.dll
libvorbisfile.lib
libvorbisfile.dll
I dragged all of them in my project's Libraries folder, already added to the project, and included them in the Linker->Input (only the .lib).
Next I copied the headers to my project's Includes folder, also already added to the project, with the files:
ogg/ogg.h
ogg/os_types.h
vorbis/codec.h
vorbis/vorbisenc.h
vorbis/vorbisfile.h
Then I added some code, and I get the error "The program can't start because libvorbisfile.dll is missing from the computer."
And I'm pretty sure the file IS in the Library folder and properly defined in the properties.
Did I do something wrong along the way?
How can I figure what is wrong so I can fix it?
I already tried putting the .dll in the project's folder and in the Windows/System32 folder as well, didn't work.
The library folder is fine for your .lib files, but it's looking for the .dll at run time, which your project settings have no effect on. Windows looks in a few places for a .dll, but the easiest way to get your program to run is to put the .dlls in your working directory, which is where ever you run your executable from (probably the same directory as the .exe file).

Trying to figure out Xcode directory system

I'm a bit stuck trying to get box2D to compile and I think it's because I don't quite understand how Xcode handles its build directories.
Box2D is folder containing a set of header and source files (in various subdirectories, etc). I've added the Box2D folder to a coco touch static library project in Xcode and when I try to compile I get errors about header files not being found such as <Box2D/Common/b2BlockAllocator.h>.
I found that if I simply include the header with #include "b2BlockAllocator.h" it compiles fine and Xcode actually finds the file.
So I'm a bit stuck here, I'm assuming I need to find a way to get all includes to begin searching from the root project directory and not from the source files location but I'm not sure how I can do that in Xcode...
Any ideas?
<Box2D/Common/b2BlockAllocator.h> should be found in a directory called Box2D/Common. You said that Box2D contains a set of header and source files. Are some of these headers in a subdirectory of Box2D called Common, or are they all directly under Box2D? If it's the latter, then that's your problem.
OK I figured it out!
In the targets settings page look for 'header search paths' and add the root build directory of your project to it.