构建和链接Crypto ++的测试代码 [英] Building and linking test code for Crypto++

查看:291
本文介绍了构建和链接Crypto ++的测试代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为项目的Crypto ++库编写一些简单的测试代码.我还没有设法建立自己的代码.它编译良好,问题出在链接中.我还是Visual Studios的新手,但是我使用的是VS10.我遇到的错误是:

I'm trying to write some simple test code for the Crypto++ library for a project. I have yet to manage to get my own code to build though. It compiles fine, the problem comes in linking. I'm still pretty new to Visual Studios, but I'm using VS10. The errors I'm getting are:

1>sec_test.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CryptoPP::DES::Base::ProcessAndXorBlock(unsigned char const *,unsigned char const *,unsigned char *)const " (?ProcessAndXorBlock@Base@DES@CryptoPP@@UBEXPBE0PAE@Z)
1>sec_test.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CryptoPP::DES::Base::UncheckedSetKey(unsigned char const *,unsigned int,class CryptoPP::NameValuePairs const &)" (?UncheckedSetKey@Base@DES@CryptoPP@@UAEXPBEIABVNameValuePairs@3@@Z)

我已经尝试了在链接方面可以在文档中找到的所有内容.我以前从未链接过DLL,但是这些是我尝试连接时遇到的错误.如果我尝试做我认为与静态库版本链接的事情,那么我会得到更多.

I've tried everything I can find in the documentation in terms of linking. I've never linked against a DLL before, but these are the errors I get when I try to. If I try to do what I think is linking against the static library version, I get even more.

我应该注意,目前我正在尝试测试纯DES.特别是,为了安全起见,以下是我正在进行的API调用:

I should note, I'm trying to test pure DES at the moment. In particular, here are the API calls I'm making, just to be safe:

DES::Encryption  DES_encrypt;
DES_encrypt.SetKey(key, 64);
DES_encrypt.ProcessAndXorBlock(plaintext, NULL, ciphertext);

DES::Decryption DES_decrypt;
DES_decrypt.SetKey(key, 64);
DES_decrypt.ProcessAndXorBlock(ciphertext, NULL, decrypted);

如果有人可以提供帮助或向正确的方向指点我,我将非常有义务.

If anyone can help, or point me in the right direction, I'd be much obliged.

推荐答案

首先要检查的是您的项目属性(右键单击项目,单击Properties).

First thing to check is your project properties (right click on project, click Properties).

需要在Linker->Input->Additional Dependencies字段中通过绝对路径或结合其他VS路径属性来指定外部库.

External libraries need to be specified in the Linker->Input->Additional Dependencies field, either by absolute path or in conjunction with the other VS path properties.

您可以查看Linker->Command Line并检查所需的.lib文件是否已真正传递到链接器.

You can look in Linker->Command Line and check that the .lib files you want are actually being passed to the linker.

另一种方法是关闭Linker->General选项中的Suppress Startup Banner选项,然后检查生成的输出以确保它具有所需的内容.

An alternate method is to turn off the Suppress Startup Banner option in the Linker->General options, and then check the build output to make sure it has what you want.

如果知道要链接的库,则另一个有用的技巧是在VS命令提示符下检查strings命令(在linux或cygwin中)或dumpbin /HEADERS的输出.您可以查看这些命令的输出,以查找缺少VS声明的符号,以验证它是否确实在.lib文件中定义.有时,较大的软件包包含多个.lib文件,因此这可以帮助确保您链接的是具有所需符号的文件.

If you know that the libraries you want are being linked, another useful trick is to check the output of the strings command (in linux or cygwin) or dumpbin /HEADERS in the VS command prompt. You can look through the output of these commands for the symbol VS claims is missing to verify that it really is defined in the .lib file. Sometimes larger software packages have multiple .lib files, so this can help make sure you are linking the one that has the symbol you want.

这篇关于构建和链接Crypto ++的测试代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆