Sto usando crypto ++ in C++ linux. Ecco il mio codice semplice:Riferimento non definito a 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] << " ";
}
}
}
}
quando l'eseguo, alcuni Errore:
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)'
Poi, ho usato il comando
gcc -o test test.cpp -L/usr/lib/crypto++ -lcrypto++
ma questo errore ancora lì:
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)'
Come posso correggere questo errore? C'è qualcosa che non va nel mio codice?
Sto installando Crypto ++ utilizzando gestore di pacchetti synaptic per questo pacchetto:..
libcrypto++-utils
libcrypto++8
libcrypto++8-dbg
libcrypto++-dev
libcrypto++-doc
e libcrypto ++ una e libcrypto ++ così può essere trovato in/usr/lib/
Grazie in anticipo.
ho cercato uso g ++ per compilare, ma quelli l'errore ancora lì. quale codice C++ dovrei collegare? Grazie. – user1533464
credo che AlignedAllocate (unsigned int) sia usato in crypto ++/secblock.h che include crypto ++/misc.h dove AlignedAllocate (unsigned int) è dichiarato, ma in qualche modo l'implementazione di AlignedAllocate (unsigned int) non trovata, e questo errore si è verificato. cosa dovrei fare? – user1533464
ho provato ad includere crypto ++/misc.h nel mio programma, ma questi errori si sono ancora verificati. – user1533464