How to include the new CryptoPP lib in 4.11?

I am currently porting one of my projects to 4.11. I was already using a staticly linked cryptoPP library, but since it is now include in the engined I removed mine and tried to include the built-in.

On my Build.cs I added

    PublicDependencyModuleNames.AddRange(new string[] { "CryptoPP" });

          if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
          {
            AddThirdPartyPrivateStaticDependencies(Target,"CryptoPP");
         }

    PublicIncludePathModuleNames.Add("CryptoPP");

It seems to import it however when I try to include it on any .h file of mine like this

#include “CryptoPP/5.6.2/include/rsa.h”

I get a VS compiler errors:

cannot open source file “CryptoPP/5.6.2/include/rsa.h” (…)

(#include “rsa.h” results in the same error)

What am I doing wrong? Thanks.

I finally managed to do it in 4.12.2. For some reason it just worked this time, I included as any other engine module. It did throw a linker error as the .lib binaries distributed with the engine were compiled with a previous version of visual studio. I managed to fix it by compiling the lib myself with VS 2015 community and then replacing it in the engine third party folder.

Hi. I’m trying to get Cryptopp working. I’m newish to unreal and c++, but not to game engines or programming per se.
I’m using UE 4.12.5
The only reference to CrytoPP I can find in the unreal folder is:
\Engine\Source\ThirdParty\CryptoPP\CryptoPP.Build.cs
I’ve tried the code in your original post, but with the same ‘cannot open source’ error.
Am I supposed to copy the cryptopp source code into my project and have unreal build it?
Any information that would help me move forward would be much appreciated.
Thanks.

I think you might be missing the “PublicIncludePaths”. Heres how I got it to work on 4.12 and above.

    PublicDependencyModuleNames.AddRange(new string[] { "CryptoPP" });

    if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
    {
        AddEngineThirdPartyPrivateStaticDependencies(Target, "CryptoPP");
    }

    PublicIncludePathModuleNames.Add("CryptoPP"); 


    PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "CryptoPP", "5.6.2/include"));

    PublicIncludePaths.Add("CryptoPP/5.6.2/include");

You may need to refresh the VS studio project from the editor after this but you should be able to include files after this.
Also bear in mind that I had to compile cryptoPP myself using visual studio community 2015 and replace the .lib file in the engine /ThirdParty/ folder. Otherwise I would get an error saying the library had been compiled using VS 2013.

After this you probably will be able to use CryptoPP in the editor and development builds, unfortunatly the work is not done yet :frowning: it won’t ship in the “Shipping” build so you’ll have to do this:

I also had to add a UEBuildConfiguration.bForceEnableExceptions = true; to my Build.cs file in order for it to ship.

Let me know if you encounter any other issues.

Hi, thanks for your help on this.
I’m still having issues.
I’ve compiled the lib, placed it in engine/thirdparty/cryptopp/lib/x64/vs2013 (as indicated by crypto.build.cs)
I’ve copied the headers into projects/thirdparty/cryptopp/5.6.2/include
I’ve started a new blank c++ project and added a new c++ Actor class.
I’ve copied the above code into project.build.cs,
plus the ModulePath/ThirdPartyPath definitions from A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums
(also updated the obsolete code, added ‘using System.IO’).

A clean build at this point returns a string of errors in engine header files, starting with:
“C2653 ‘FCrc’: is not a class or namespace name.” in TypeHash.h
2>G:\Epic Games\4.12\Engine\Source\Runtime\Core\Public\Templates\TypeHash.h(109): error C2653: 'FCrc': is not a class or namespace name 2>G:\Epic Games\4.12\Engine\Source\Runtime\Core\Public\Templates\TypeHash.h(109): error C3861: 'Strihash_DEPRECATED': identifier not found 2>G:\Epic Games\4.12\Engine\Source\Runtime\Core\Public\Serialization\ArchiveBase.h(1332): warning C4266: 'FArchive &FArchive::operator <<(FAssetPtr &)': no override available for virtual member function from base 'FArchive'; function is hidden ... ...

commenting out the line
PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "CryptoPP", "5.6.2/include"));
removes the odd errors and replaces with a simple
"LNK1181: cannot open input file ‘cryptlib.lib’

And of course, theheades cannot be found when included in the newActor class.

I’m too bogged down with work to follow this up right now, but I wanted to report back. I’ve probably just missed something obvious. I’ll spend some time on it later in the week.

I fixed the odd errors by only having the required headers in the include folder. Then I got .lib not found again, at which point I gave up and used PublicAdditionalLibraries.Add(…) instead of loading the CryptoPP module.

This set up compiles, includes and all, but I can’t verify that it’s working yet.

It seems you’re on the right track, I had those errors also. For the deprecated warning I usually just comment out line 109 in “TypeHash.h”, it should not interfere with the normal functioniong of the engine since it’s a deprecated function anyways and there is no code in it, but it should cause the error to disappear. You do Not need to recompile the engine. Just comment the line on visual studio or navigate to the folder in explorer and comment line 109.

I think the other warning disappears as well as I don’t have it.

I know it’s a pain to include this lib but it’s well worth it in the end =)

Great post ! I aslo wants to know [alarm windows][1]

[1]: https://oneshottech.com/alarms-in-windows-10 more about this. Thanks for sharing.