2014-03-27 3 views
3

Я скачал Crypto++ 5.62 и построил его с настройками проекта по умолчанию. В моем проекте я установил путь к cryptopp.lib и определил его имя в «Дополнительные зависимости». Оба Crypto ++ и мой проект - VS 2008.нерешенный внешний символ, но dumpbin говорит, что это нормально

Во время строительства моего проекта я получаю:

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" ([email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@B) 

main.obj : error LNK2001: unresolved external symbol 
    "bool (__cdecl* CryptoPP::g_pAssignIntToInteger)(class type_info const &,void *,void const *)" ([email protected]@@[email protected]@[email protected]) 

dumpbin /all cryptopp.lib показывает мне в секции общественных символов

19471C [email protected]@@[email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@B 

1D6F30 [email protected]@@[email protected]@[email protected] 

Что случилось потом? Почему линкер не может найти символы?

UPD:

компоновщик командной строки из моего проекта настройки

/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

+0

Отсутствует зависимость? включите? – Brian

+0

@staticx: Я не уверен, что понимаю вас. Не могли бы вы объяснить более подробно? – fogbit

+0

Вы можете посмотреть окно вывода и посмотреть, какая команда link.exe используется? – evpo

ответ

5

Попробуйте добавить CRYPTOPP_IMPORTS в ваш проект определяет.

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:

#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 

Если это не работает ...

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 (держать его от отбрасываются). К сожалению, на данный момент ничего не приходит в голову.


DEFAULT_CHANNEL объявлен в cryptlib.h и памяти, выделенный в 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, а затем задайте другой вопрос, так как это может быть другой проблемой.

+1

#include до того, как все остальные крипто-включились и для меня. – BeschBesch

Смежные вопросы