编译Ubuntu提供的Crypto ++

GSP*_*ler 8 ubuntu compilation crypto++

我尝试使用apt-get:安装Crypto ++ sudo apt-get install libcrypto++-dev libcrypto++-doc libcrypto++-utils.然后我尝试编译非常简单的程序,如:

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

using namespace std;
using namespace CryptoPP;

int main()
{
    cout << "Yo, man!" << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

它导致了fatal error: aes.h: No such file or directory.

我是一个新的Ubuntu用户(Windows之前),所以我做了一些研究,但是大多数人说输入一个命令足以获得Crypto ++库的存储库并使其工作.嗯,这不是我的情况.

小智 9

如果按照说明(使用apt-get)安装了库,那么试试这个:

#include <crypto++/aes.h>
#include <crypto/modes.h>
Run Code Online (Sandbox Code Playgroud)

而不是这个:

#include "aes.h"
#include "modes.h"
Run Code Online (Sandbox Code Playgroud)

你应该使用#include <crypto++/...>因为Ubuntu将它们安装在它的"系统"中,这意味着预处理器在处理它们时会以特定的顺序查看特定的位置.另请参阅#include和#include"filename"之间的区别是什么?.

另请注意,在Fedora和Red Hat上,您可以使用#include <cryptopp/...>,而不是#include <crypto++/...>.如果您针对Crypto ++定位多个操作系统,请参阅如何使用autotools更改包含文件路径?.