尚未解析的外部符号,但dumpbin表示还可以 [英] unresolved external symbol, but dumpbin says it's ok

查看:118
本文介绍了尚未解析的外部符号,但dumpbin表示还可以的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了 Crypto ++ 5.62,并使用默认项目设置进行了构建.在我的项目中,我设置了 cryptopp.lib 的路径,并在其他依赖项"中定义了它的名称.Crypto ++和我的项目-VS 2008.

I downloaded Crypto++ 5.62 and built it with default project settings. In my project I set up the path to cryptopp.lib and defined its name in "Additional Dependencies". Both Crypto++ and my project - VS 2008.

在构建项目期间,我得到:

During building of my project I get:

main.obj : error LNK2001: unresolved external symbol 
  "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const CryptoPP::DEFAULT_CHANNEL" (?DEFAULT_CHANNEL@CryptoPP@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@B)

main.obj : error LNK2001: unresolved external symbol 
  "bool (__cdecl* CryptoPP::g_pAssignIntToInteger)(class type_info const &,void *,void const *)" (?g_pAssignIntToInteger@CryptoPP@@3P6A_NABVtype_info@@PAXPBX@ZA)

dumpbin/all cryptopp.lib 在公共符号部分显示了我

dumpbin /all cryptopp.lib shows me in the public symbols section

19471C _imp_?DEFAULT_CHANNEL@CryptoPP@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@B

1D6F30 __imp_?g_pAssignIntToInteger@CryptoPP@@3P6A_NABVtype_info@@PAXPBX@ZA

那怎么了?为什么链接器找不到符号?

What's wrong then? Why the linker can't find the symbols?

更新:

项目设置中的链接器命令行

linker command line from my project settings

/OUT:"C:\ Projects \ crypto_hash \ Debug \ crypto_hash.exe"/NOLOGO/LIBPATH:"e:\ libs \ cryptopp \ cryptopp562 \ cryptopp \ Win32 \ DLL_Output \ Debug"/MANIFEST/MANIFESTFILE:"Debug \ crypto_hash.exe.intermediate.manifest"/MANIFESTUAC:"level ='asInvoker'uiAccess ='false'"/DEBUG/PDB:"C:\Projects\crypto_hash\Debug\crypto_hash.pdb"/DYNAMICBASE/NXCOMPAT/MACHINE:X86/ERRORREPORT:PROMPT cryptopp.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

推荐答案

尝试将 CRYPTOPP_IMPORTS 添加到您的项目定义中.

Try adding CRYPTOPP_IMPORTS to your project defines.

来自 config.h :

#ifdef CRYPTOPP_EXPORTS
# define CRYPTOPP_IS_DLL
# define CRYPTOPP_DLL __declspec(dllexport)
#elif defined(CRYPTOPP_IMPORTS)
# define CRYPTOPP_IS_DLL
# define CRYPTOPP_DLL __declspec(dllimport)
#else
# define CRYPTOPP_DLL
#endif

或包含Crypto ++的 dll.h .它设置 CRYPTOPP_IMPORTS :

Or include Crypto++'s dll.h. It sets CRYPTOPP_IMPORTS:

#if !defined(CRYPTOPP_IMPORTS) && !defined(CRYPTOPP_EXPORTS) && !defined(CRYPTOPP_DEFAULT_NO_DLL)
# ifdef CRYPTOPP_CONFIG_H
#  error To use the DLL version of Crypto++, this file must be included before any other Crypto++ header files.
# endif
# define CRYPTOPP_IMPORTS
#endif


如果那不起作用...


If that does not work...

g_pAssignIntToInteger 来自 algparams.cpp :

$ grep -R g_pAssignIntToInteger *
algparam.cpp:PAssignIntToInteger g_pAssignIntToInteger = NULL;
algparam.h:CRYPTOPP_DLL extern PAssignIntToInteger g_pAssignIntToInteger;
algparam.h:     if (!(g_pAssignIntToInteger != NULL && typeid(T) == typeid(int) && g_pAssignIntToInteger(valueType, pValue, &m_value)))
integer.cpp:    if (!g_pAssignIntToInteger)
integer.cpp:        g_pAssignIntToInteger = AssignIntToInteger;

查看 algparam.h 中的声明:

// to allow the linker to discard Integer code if not needed.
typedef bool (CRYPTOPP_API * PAssignIntToInteger)(const std::type_info &valueType, void *pInteger, const void *pInt);
CRYPTOPP_DLL extern PAssignIntToInteger g_pAssignIntToInteger;

以及 algparam.cpp 中的实现:

#ifndef CRYPTOPP_IMPORTS
...

NAMESPACE_BEGIN(CryptoPP)    
PAssignIntToInteger g_pAssignIntToInteger = NULL;
...

因此,您可能需要更改实现以确保代码使用 g_pAssignIntToInteger (以防止被丢弃).不幸的是,此刻什么都没想到.

So you might need to change the implementation to ensure the code uses g_pAssignIntToInteger (to keep it from being discarded). Unfortunately, nothing comes to mind at the moment.

DEFAULT_CHANNEL cryptlib.h 中声明,并在 cryptolib.cpp 中分配存储空间:

DEFAULT_CHANNEL is declared in cryptlib.h and has storage allocated in cryptolib.cpp:

$ grep -R DEFAULT_CHANNEL *
...
cryptlib.cpp:const std::string DEFAULT_CHANNEL;
...
cryptlib.h:extern CRYPTOPP_DLL const std::string DEFAULT_CHANNEL;
...

这可能是一个不同的问题,因为我不习惯看到 DEFAULT_CHANNEL 的问题.查看 CRYPTOPP_IMPORTS 为您工作的方式,然后问一个不同的问题,因为这可能是一个不同的问题.

This might be a different problem since I'm not used to seeing issues with DEFAULT_CHANNEL. See how CRYPTOPP_IMPORTS works for you, and then ask a different question since this might be a different problem.

这篇关于尚未解析的外部符号,但dumpbin表示还可以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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