Używam crypto ++ w c ++ linux. Oto mój prosty kod:Niezdefiniowane odwołanie do CryptoPP :: AlignedAllocate (unsigned int)
#include <iostream>
#include <fstream>
#include <string.h>
#include "crypto++/cryptlib.h"
#include "crypto++/modes.h"
#include "crypto++/filters.h"
#include "crypto++/aes.h"
#include "crypto++/osrng.h"
#include "crypto++/strciphr.h"
using namespace std;
using namespace CryptoPP;
ifstream::pos_type size;
char * memblock;
int length;
char * _iv[AES::BLOCKSIZE];
char * keys[AES::MAX_KEYLENGTH];
void encriptCTR(byte * outbyte, const byte * inbyte, const byte * key, const byte * iv);
void encriptCTR(byte * outbyte, const byte * inbyte, const byte * key, const byte * iv)
{
size_t inbyte_len = strlen((const char *)inbyte);
CTR_Mode<AES>::Encryption ctr_encription(key, strlen((const char*)key), iv);
ctr_encription.ProcessData(outbyte, inbyte, inbyte_len);
}
int main()
{
ifstream file;
file.open("testaja", ios::binary);
if (file.is_open())
{
file.seekg (0, ios::end);
length = file.tellg();
memblock = new char [length];
file.seekg (0, ios::beg);
file.read (memblock, length);
if (!file)
{
int a;
a = (int)file.gcount();
file.clear();
}
else
{
file.close();
for (int i = 0; i < length; ++i)
{
cout << hex << (int)memblock[i] << " ";
}
}
}
}
Podczas uruchamiania go jakiś błąd:
undefined reference to `CryptoPP::AlignedAllocate(unsigned int)'
undefined reference to `CryptoPP::UnalignedAllocate(unsigned int)'
undefined reference to `CryptoPP::AlignedDeallocate(unsigned int)'
undefined reference to `CryptoPP::UnalignedDeallocate(unsigned int)'
Następnie użyłem komendy
gcc -o test test.cpp -L/usr/lib/crypto++ -lcrypto++
ale błąd ten nadal istnieje:
undefined reference to `CryptoPP::AlignedAllocate(unsigned int)'
undefined reference to `CryptoPP::UnalignedAllocate(unsigned int)'
undefined reference to `CryptoPP::AlignedDeallocate(unsigned int)'
undefined reference to `CryptoPP::UnalignedDeallocate(unsigned int)'
Jak mogę naprawić ten błąd? Czy jest coś nie tak z moim kodem?
ja instalacji crypto ++ za pomocą synaps menedżera pakietów dla tego pakietu..
libcrypto++-utils
libcrypto++8
libcrypto++8-dbg
libcrypto++-dev
libcrypto++-doc
i libcrypto ++ ai libcrypto ++ więc można znaleźć w/usr/lib/
z góry dzięki.
Próbowałem use g ++ skompilować, ale ci, błąd nadal. jaki kod C++ powinienem połączyć? dzięki. – user1533464
Wierzę, że AlignedAllocate (unsigned int) używane w crypto ++/secblock.h, które zawierają crypto ++/misc.h gdzie AlignedAllocate (unsigned int) jest zadeklarowane, ale jakoś nie znaleziono implementacji AlignedAllocate (unsigned int) i wystąpił ten błąd. co powinienem zrobić? – user1533464
Próbowałem włączyć do mojego programu crypto ++/misc.h, ale błąd nadal był oszałamiający. – user1533464