ubuntucompilationcrypto++

Compiling against Crypto++ provided by Ubuntu


I tried to install Crypto++ using apt-get: sudo apt-get install libcrypto++-dev libcrypto++-doc libcrypto++-utils. And then I tried to compile very simple program like:

#include <iostream>
#include "aes.h"
#include "modes.h"

using namespace std;
using namespace CryptoPP;

int main()
{
    cout << "Yo, man!" << endl;
    return 0;
}

It resulted in fatal error: aes.h: No such file or directory.

I'm a new Ubuntu user (Windows before), so I've done some research, but most people say that typing that one command is enough to get repository with Crypto++ library and make it work. Well, it is not in my case.


Solution

  • If you installed the library as you said (using apt-get), then try this:

    #include <crypto++/aes.h>
    #include <crypto++/modes.h>
    

    Instead of this:

    #include "aes.h"
    #include "modes.h"
    

    You should use the #include <crypto++/...> because Ubuntu installs them in its "system", which means the preprocessor will look in particular places in a particular order when processing them. Also see What is the difference between #include and #include “filename”?.

    Also note that on Fedora and Red Hat, you would use #include <cryptopp/...>, not #include <crypto++/...>. If you are targeting multiple operating systems for Crypto++, then see How to change the include file path with autotools?.