【发布时间】:2015-09-09 05:41:36
【问题描述】:
我在 Windows 中编译 cryptopp 项目时遇到以下错误。
C:\Users\Sajith\AppData\Local\Temp\ccxq8O8x.o:aescbc.cpp:(.text$_ZN8CryptoPP20AllocatorWithCleanupIhLb1EE8allocateEjPKv[
__ZN8CryptoPP20AllocatorWithCleanupIhLb1EE8allocateEjPKv]+0x2e): undefined reference to `CryptoPP::AlignedAllocate(unsig
ned int)'
C:\Users\Sajith\AppData\Local\Temp\ccxq8O8x.o:aescbc.cpp:(.text$_ZN8CryptoPP20AllocatorWithCleanupIhLb1EE10deallocateEPv
j[__ZN8CryptoPP20AllocatorWithCleanupIhLb1EE10deallocateEPvj]+0x28): undefined reference to `CryptoPP::AlignedDeallocate
(void*)'
collect2.exe: error: ld returned 1 exit status
下面是我的编译命令:
mingw32-g++.exe -o .\aestest2.exe .\aescbc.cpp -I "C:\cryptopp\Include" -L "C:\cryptopp\Lib" -lcryptopp
我的 libcryptopp.a 位于 C:\cryptopp\Lib
我试图找出AlignedDeallocate 的声明位置,但找不到。
引发此错误的程序部分如下:
try
{
cout << "plain text: " << plain << endl;
CBC_Mode< AES >::Encryption e;
e.SetKeyWithIV(key, sizeof(key), iv);
// The StreamTransformationFilter removes
// padding as required.
StringSource s(plain, true,
new StreamTransformationFilter(e,
new StringSink(cipher)
) // StreamTransformationFilter
); // StringSource
#if 0
StreamTransformationFilter filter(e);
filter.Put((const byte*)plain.data(), plain.size());
filter.MessageEnd();
const size_t ret = filter.MaxRetrievable();
cipher.resize(ret);
filter.Get((byte*)cipher.data(), cipher.size());
#endif
}
catch(const CryptoPP::Exception& e)
{
cerr << e.what() << endl;
exit(1);
}
建议赞赏!
【问题讨论】:
-
不管怎样,上面的示例应该可以工作。代码看起来不错,编译它的命令格式也不错。