【问题标题】:Compiling against Crypto++ provided by Ubuntu针对 Ubuntu 提供的 Crypto++ 进行编译
【发布时间】:2013-10-04 18:11:13
【问题描述】:

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

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

using namespace std;
using namespace CryptoPP;

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

结果是 fatal error: aes.h: No such file or directory

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

【问题讨论】:

    标签: ubuntu compilation crypto++


    【解决方案1】:

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

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

    而不是这个:

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

    您应该使用#include &lt;crypto++/...&gt;,因为 Ubuntu 将它们安装在其“系统”中,这意味着预处理器在处理它们时会以特定顺序查找特定位置。另见What is the difference between #include and #include “filename”?

    另请注意,在 Fedora 和 Red Hat 上,您将使用 #include &lt;cryptopp/...&gt;,而不是 #include &lt;crypto++/...&gt;。如果您针对 Crypto++ 的多个操作系统,请参阅How to change the include file path with autotools?

    【讨论】:

      【解决方案2】:

      确保还包括编译命令的-lcryptopp 标志!

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2011-12-19
      • 2011-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-24
      • 2019-07-01
      • 1970-01-01
      • 2014-05-09
      相关资源
      最近更新 更多