Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem building and using Crypto++ on Windows #390

Closed
seekM opened this issue Mar 14, 2017 · 3 comments
Closed

Problem building and using Crypto++ on Windows #390

seekM opened this issue Mar 14, 2017 · 3 comments
Labels

Comments

@seekM
Copy link

seekM commented Mar 14, 2017

Hi,

I'd like to use crypto++. I am using Windows 7 (64 bit). The last days I have tried to build it using different Visual Studio versions but I did not have success. I'd like to describe the steps I did and ask for help what I did wrong.

  • Here I read that building Crypto++ should work with Visual Studio 2012, so I downloaded and installed the "Microsoft Visual Studio 2012 Express" version.
  • I downloaded the cryptop++ version 5.6.5.
  • I unzip crypto++ and open the cryptest.sln file with Visual Studio 2012.
  • VS2012 tells me that at least one of the projects is intended to be used with an older version of the Visual C++ Compiler and the respective libraries. It gives me the option to update the projects such that libraries and the compiler of VS2012 can be used.
  • I agree to update the projects. (What I think happens now is that Project-> Properties -> General -> Platform Toolset is set to v110).
  • I choose I want to create a static library. According to the Readme.txt I have to build cryptest with the Non-DLL-Import Configuration . According to the Readme.txt there is also a DLL-Import Configuration. I don't know how I can choose in VS2012 which configuration to use. At the top in VS2012 I choose x64 (instead of Win32), Release (instead of Debug) and and right-click on cryptest and choose build.
  • The output says that everything was successfull, including

cryptest.vcxproj -> C:\cryptopp565\x64\Output\Release\cryptest.exe
cryptlib.vcxproj -> C:\cryptopp565\x64\Output\Release\cryptlib.lib

Among others, the following was given in the output as well:

cl : warning D9002: Unkown option "/arch:SSE2" will be ignored.
elgamal.obj / dh.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library.

  • I open cmd.exe, move to C:\cryptopp565\x64\Output\Release, copy the TestData and TestVector folders into this folder and execute cryptest.exe v. It ends with All tests are passed!.

  • In VS2012 I create a new console application project. I copy the sample code for AES encryption from this StackOverflow anser into my ConsoleApplication.cpp.

  • As I understand it, I now have to include the header files of crypto++ and make the static library known to the project:

  • I right-click on my ConsoleApplication project and go to Properties > Configuration Properties > VC++ Directories >Include Directories. There I add C:\cryptopp565 (the folder where the headers are located).

  • I right-click on my ConsoleApplication project and go to Properties > Configuration Properties > VC++ Directories >Library Directories. There I add C:\cryptopp565\x64\Output\Release (the folder where cryptlib.lib is located).

  • I right-click on my ConsoleApplication project and go to Properties > Configuration Properties > Linker > Input > Additional Dependencies . There I add cryptlib.lib (which is in the folder stated one bullet point above).

  • Now all the red markings in ConsoleApplication.cpp disappear.

  • I right-click on my ConsoleApplication project and choose build. 50 errors are displayed in the output window. This is one of them (the rest have the same shape):

error LNK2001: unresolved external symbol ""protected: virtual void __thiscall CryptoPP::CBC_Decryption::ResizeBuffers(void)" (?ResizeBuffers@CBC_Decryption@CryptoPP@@MAEXXZ)". C:\cryptopp565\ConsoleApplication\ConsoleApplication.obj ConsoleApplication

Does it mean that some definitions / implemenations for some header files are missing? Does more than the cryptlib.lib file have to be included? How can this be fixed?

@noloader
Copy link
Collaborator

noloader commented Mar 14, 2017

Don't use the DLL on Windows. The DLL is the FIPS DLL, and it only provides FIPS 140-2 algorithms. You still need to link to the static version of the library to get the missing classes. Its an awful setup that constantly confuses users. Also see Visual Studio on the wiki.

I think the best course of action for you is to use either Debug or Release configurations. Ignore the DLL-Import configurations. If you want a DLL, then create a wrapper DLL, export what you want, and then link to the static version of the Crypto++ library.


Does it mean that some definitions / implemenations for some header files are missing? Does more than the cryptlib.lib file have to be included? How can this be fixed?

It sounds like your project's configuration is not quite right. Perhaps you should checkout MSDN about setting up a VS project; or ask on Stack Overflow or the user list.

@noloader noloader changed the title Problem building and using cryptopp (Windows) Problem building and using Crypto++ on Windows Mar 14, 2017
@seekM
Copy link
Author

seekM commented Mar 14, 2017

Don't use the DLL on Windows. The DLL is the FIPS DLL, and it only provides FIPS 140-2 algorithms. You still need to link to the static version of the library to get the missing classes. Its an awful setup that constantly confuses users. Also see Visual Studio on the wiki.

I think the best course of action for you is to use either Debug or Release configurations. Ignore the DLL-Import configurations. If you want a DLL, then create a wrapper DLL, export what you want, and then link to the static version of the Crypto++ library.

Ah, thanks, I think I understand this now.
As I used the Release configuration that should not have caused the problem. In principle the static cryptlib.lib and header files should suffice to build the sample program, shouldn't they? I'm pretty sure cryptlib.lib is recognized by the linker, because if I leave out this step (as described above)

I right-click on my ConsoleApplication project and go to Properties > Configuration Properties > VC++ Directories >Library Directories. There I add C:\cryptopp565\x64\Output\Release (the folder where cryptlib.lib is located).

and build the project, the output says "error LNK1181: cannot open input file "cryptlib.lib"". Therefore I assume that when including the step above and this message doesn't appear cryptlib.lib can be accessed.

Thank you, I'll write to the mailing list.

@noloader
Copy link
Collaborator

noloader commented Mar 15, 2017

@seekM,

I see you visited the user list. We will get things sorted out with you on the list.

I'm going to close this out now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants