fatal error: blake2.h: No such file or directory

fatal error: blake2.h: No such file or directory

我正在使用 RaspberryPi,Crypto++6 是通过 apt 唯一可用的版本,我不能包含哈希函数库 blake2,并且 /usr/include/cryptopp/blake2.h 不存在,我也尝试安装它通过 github 手动安装,下面是我如何手动安装它,但仍然不起作用,并且 blake.h 也不存在于 include 文件夹中,我该怎么办?提前谢谢你!

我使用 <crypto++/libname.h> 因为我使用的是基于 Debian 的发行版(stretch),但是当我尝试 <cryptopp/blake.h> 时它起作用了,这是在我手动安装库之后,现在我得到了另一个错误,我应该使用 crypto++ 还是 cryptopp

/tmp/ccTmS4UQ.o: In function `main':
test.cpp:(.text+0x24): undefined reference to `CryptoPP::BLAKE2b::BLAKE2b(bool, unsigned int)'
/tmp/ccTmS4UQ.o: In function `CryptoPP::BLAKE2b::~BLAKE2b()':
test.cpp:(.text._ZN8CryptoPP7BLAKE2bD2Ev[_ZN8CryptoPP7BLAKE2bD5Ev]+0x74): undefined reference to `vtable for CryptoPP::BLAKE2b'
test.cpp:(.text._ZN8CryptoPP7BLAKE2bD2Ev[_ZN8CryptoPP7BLAKE2bD5Ev]+0x78): undefined reference to `vtable for CryptoPP::BLAKE2b'
collect2: error: ld returned 1 exit status

并且:

uname -a
Linux raspberrypi 4.19.42-v7+ #1219 SMP Tue May 14 21:20:58 BST 2019 armv7l GNU/Linux

ldconfig -p | grep crypto++
libcrypto++.so.6 (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libcrypto++.so.6
libcrypto++.so (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libcrypto++.so

还有一个程序:

#include <crypto++/cryptlib.h>
#include <crypto++/blake2.h>

#include <iostream>

int main (int argc, char* argv[])
{
    using namespace CryptoPP;
    BLAKE2b hash;   
    std::cout << "Name: " << hash.AlgorithmName() << std::endl;
    std::cout << "Digest size: " << hash.DigestSize() << std::endl;
    std::cout << "Block size: " << hash.BlockSize() << std::endl;

    return 0; 
}

我已经卸载了软件包,然后通过 github 手动重新安装 sudo git clone https://github.com/weidai11/cryptopp cd cryptopp sudo make sudo make install

我摆脱了 blake2.h 丢失的错误,但是我遇到了许多未定义的引用错误,例如 (/tmp/cc9AY7g8.o:(.rodata._ZTIN8CryptoPP25MessageAuthenticationCodeE[_ZTIN8CryptoPP25MessageAuthenticationCodeE]+0x18): undefined reference to typeinfo for CryptoPP::HashTransformation)

我正在用一个 shell 脚本编译示例,如下所示:

g++ -lrt -lpthread -lstdc++ -lcrypto -lcryptopp "" \
      "$LIBRARY_DIR/arduPiLoRa.o" \
      "$ARDUPIAPI_DIR/arduPiUART.o" \
      "$ARDUPIAPI_DIR/arduPiUtils.o" \
      "$ARDUPIAPI_DIR/arduPiMultiprotocol.o" \
      "$ARDUPI_DIR/arduPi.o" \
      "$LIBRARY_DIR/ecdh.o" \
      "$LIBRARY_DIR/aes.o" \
      -I"$ARDUPI_DIR" \
      -I"$ARDUPIAPI_DIR" \
      -I"$LIBRARY_DIR" \
      -o "_exe" 

但是我直接用g++ -o blake2 blake2.cpp -lcryptopp编译时未定义引用的错误消失了,我编译成功了,

我已经修改了shell脚本,现在终于可以用了,但是我不太明白,

g++ -DNDEBUG -g3 -O2 -Wall -Wextra -lrt -lpthread -lstdc++ -lcrypto -lcryptopp -l:libcryptopp.a "" \
  "$LIBRARY_DIR/arduPiLoRa.o" \
  "$ARDUPIAPI_DIR/arduPiUART.o" \
  "$ARDUPIAPI_DIR/arduPiUtils.o" \
  "$ARDUPIAPI_DIR/arduPiMultiprotocol.o" \
  "$ARDUPI_DIR/arduPi.o" \
  "$LIBRARY_DIR/ecdh.o" \
  "$LIBRARY_DIR/aes.o" \
  -I"$ARDUPI_DIR" \
  -I"$ARDUPIAPI_DIR" \
  -I"$LIBRARY_DIR" \
  -o "_exe" \
  -l:libcryptopp.a