首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Linux中的libcrypto++

Linux中的libcrypto++
EN

Stack Overflow用户
提问于 2011-01-05 18:24:03
回答 1查看 1.3K关注 0票数 2

对于代码:

代码语言:javascript
复制
#include <fstream>

#include <iostream> //cryptopp libraries

#include "cryptopp/dll.h"

#include "cryptopp/default.h"


using namespace std;

using namespace CryptoPP;

int main()
{

 byte key[AES::DEFAULT_KEYLENGTH], iv[AES::BLOCKSIZE];

    // initialize key and iv here

    CFB_Mode<AES >::Encryption cfbEncryption(key, AES::DEFAULT_KEYLENGTH, iv);

 std::cout << "Hello world!" << std::endl;

 return 0;

}

编译时出现以下错误:$:g++ test.cpp -o tess -lcrypto++ -lpthread

/tmp/ccLR085h.o: In函数CryptoPP::AllocatorWithCleanup<unsigned char, true>::allocate(unsigned int, void const*)': test.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE8allocateEjPKv[CryptoPP::AllocatorWithCleanup<unsigned char, true>::allocate(unsigned int, void const*)]+0x2b): undefined reference toCryptoPP::AlignedAllocate(unsigned int)‘test.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE8allocateEjPKvCryptoPP::AllocatorWithCleanup::allocate(unsigned int,void const*)+0x38):未定义的对CryptoPP::UnalignedAllocate(unsigned int)' /tmp/ccLR085h.o: In functionCryptoPP::AllocatorWithCleanup::deallocate(void*,unsigned int)':test.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE10deallocateEPvjCryptoPP::AllocatorWithCleanup::deallocate(void*,unsigned int)+0x25):对CryptoPP::AlignedDeallocate(void*)' test.cpp:(.text._ZN8CryptoPP20AllocatorWithCleanupIhLb1EE10deallocateEPvj[CryptoPP::AllocatorWithCleanup<unsigned char, true>::deallocate(void*, unsigned int)]+0x32): undefined reference toCryptoPP::UnalignedDeallocate(void*)’collect2的未定义引用: ld返回1个退出状态

需要帮助。THX

EN

回答 1

Stack Overflow用户

发布于 2011-05-11 06:22:10

这一点很棘手。我怀疑您发布的编译行不是产生错误的编译行。当我这样做的时候

代码语言:javascript
复制
g++ test.cpp -o tess -lcryptopp -lpthread -L.

我没有收到任何错误,但当我收到错误时

代码语言:javascript
复制
g++ -o tess -lcryptopp -lpthread -L. test.cpp

我从一开始就收到了很多错误

代码语言:javascript
复制
/tmp/ccCSTBSy.o: In function `CryptoPP::SimpleKeyingInterface::SimpleKeyingInterface()':
SO4602996.cpp:(.text._ZN8CryptoPP21SimpleKeyingInterfaceC2Ev[CryptoPP::SimpleKeyingInterface::SimpleKeyingInterface()]+0x4): undefined reference to `vtable for CryptoPP::SimpleKeyingInterface'
/tmp/ccCSTBSy.o: In function `CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::SecBlock(unsigned int)':
SO4602996.cpp:(.text._ZN8CryptoPP8SecBlockIhNS_20AllocatorWithCleanupIhLb0EEEEC1Ej[CryptoPP::SecBlock<unsigned char, CryptoPP::AllocatorWithCleanup<unsigned char, false> >::SecBlock(unsigned int)]+0x25): undefined reference to `CryptoPP::AllocatorWithCleanup<unsigned char, false>::allocate(unsigned int, void const*)'

这看起来像是你得到的错误。

请注意,我从源代码编译了cryptopp 5.6.1,并在本例中使用的目录中放置了库的副本:因此,我需要-L.将当前目录包括在库路径搜索中。我也在使用-lcryptopp而不是-lcrypto++,因为它是我的源码生成的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4602996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档