x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.11
Tags:
more ▼

asked Apr 13 '16 at 12:12 PM in C++ Programming

avatar image

DavidNSilva
35 4 10 14

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jun 12 '16 at 09:30 AM

avatar image

DavidNSilva
35 4 10 14

avatar image Curator23 Aug 11 '16 at 09:31 AM

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.

avatar image DavidNSilva Aug 11 '16 at 12:31 PM

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 :( it won't ship in the "Shipping" build so you'll have to do this:

https://answers.unrealengine.com/questions/229449/stdtype-info-fails-to-build-in-development-configu.html

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.

avatar image Curator23 Aug 16 '16 at 01:05 PM

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 https://wiki.unrealengine.com/Linking_Static_Libraries_Using_The_Build_System (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.

avatar image Curator23 Aug 17 '16 at 05:27 PM

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.

avatar image DavidNSilva Aug 19 '16 at 11:19 AM

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 =)

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question