加密货币++ Code::blocks 未定义的引用问题
我正在尝试使用 Crypto++ (使用 Code::Blocks)创建一个 C++ 程序,但一直遇到同样的问题。我正在使用此代码的精简版本: http:// andreyvitdev.blogspot.com/2005/10/crypto-usage-sample.html ,但我无法编译它。
#include "cryptopp/blowfish.h"
#include "cryptopp/osrng.h"
using namespace CryptoPP;
int main (int argc, char** argv) {
byte key[Blowfish::DEFAULT_KEYLENGTH],
iv[Blowfish::BLOCKSIZE];
AutoSeededRandomPool rng (true);
rng.GenerateBlock(key, sizeof (key));
rng.GenerateBlock(iv, sizeof (iv));
}
我收到多个错误,从以下内容开始:“C:\Users\Utilisateur\Programming\C++\CodeBlocks\Crytp tester\main.cpp|13|对 `CryptoPP::RandomNumberGenerator::GenerateBlock(unsigned char*, unsigned int) 的未定义引用’”
我是不是漏掉了什么?不同站点上有许多对必须导入的库的引用,但我无法弄清楚它们在 crypto++ 文件夹中的位置: http://www.cryptopp.com/#download
I'm trying to create a C++ program using Crypto++ (with Code::Blocks), but keep getting stuck with the same problem. I'm using a cut-down version of this code : http://andreyvitdev.blogspot.com/2005/10/crypto-usage-sample.html
, but I can't get it to compile.
#include "cryptopp/blowfish.h"
#include "cryptopp/osrng.h"
using namespace CryptoPP;
int main (int argc, char** argv) {
byte key[Blowfish::DEFAULT_KEYLENGTH],
iv[Blowfish::BLOCKSIZE];
AutoSeededRandomPool rng (true);
rng.GenerateBlock(key, sizeof (key));
rng.GenerateBlock(iv, sizeof (iv));
}
I get multiple errors, starting with : "C:\Users\Utilisateur\Programming\C++\CodeBlocks\Crytp tester\main.cpp|13|undefined reference to `CryptoPP::RandomNumberGenerator::GenerateBlock(unsigned char*, unsigned int)'"
Am I missing something? There are many references on different sites to libraries that must be imported, but I couldn't figure out where they were in the crypto++ folder : http://www.cryptopp.com/#download
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“未定义的引用”是链接器错误 - 要么您没有构建 Crypto++ 库,要么没有告诉链接器链接到它。
不过,我不确定它是否会使用 MinGW(带有代码块的最常见编译器)进行构建。 Microsoft 编译器(以及 Visual Studio)是免费的;并使用 Code::Blocks 和 Crypto++ 进行显式测试。
"Undefined reference" is a linker error -- either you didn't build the Crypto++ library, or didn't tell the linker to link to it.
I'm not positive if it will build using MinGW (the most common compiler with Code Blocks) though. The Microsoft compilers (along with Visual Studio) are free; and are tested explicitly with both Code::Blocks and Crypto++.