3

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.

jww
  • 97,681
  • 90
  • 411
  • 885
Florian sp1rit
  • 575
  • 1
  • 7
  • 20
  • _"Adding the libcrypto.lib to the Header Files."_ What do you mean? The .lib file should be added to the projects library files, not to the headers. Maybe [this](https://stackoverflow.com/questions/24715864/problems-importing-libraries-to-my-c-project-how-to-fix-this) helps. – πάντα ῥεῖ Jan 28 '19 at 19:17
  • 2
    Strongly recommend opening up the Output tab (down at the bottom of the IDE if you haven't moved stuff around) and copying the output of a full rebuild of the project into the question along with a [mcve]. That gives us out here in Internet land a few hints about what problems you are actually running into. – user4581301 Jan 28 '19 at 19:19
  • 1
    I'm hazarding a guess... It is probably [dynamic C/C++ runtime linking](https://cryptopp.com/wiki/Visual_Studio#Runtime_Linking). You should show a typical compile command and link command, and show some of the errors you are encountering. Also, the library is called `cryptlib.lib`. There is no `libcrypto.lib`. If you really did link against `libcrypto.lib`, then it is the wrong library. – jww Jan 28 '19 at 19:22
  • Windows has excellent [CryptoAPI](https://learn.microsoft.com/en-us/windows/desktop/seccng/about-cng) built-in. You really don't need any 3rd-party library... – rustyx Jan 28 '19 at 19:48

1 Answers1

3

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

  • Yes you're right I've edited, it is better to link statically. – Benoît Bottemanne Jan 28 '19 at 19:36
  • OP will probably needs to perform the [dynamic C++ runtime](https://www.cryptopp.com/wiki/Visual_Studio#Runtime_Linking) conversion, too. It depends how the project is setup, but most people take the Visual Studio default. – jww Jan 28 '19 at 19:38