Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/151.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ VS2012静态库、控制台应用程序和clr程序上使用cryptopp的链接错误_C++_Visual Studio 2012_Dll_Static Libraries_Crypto++ - Fatal编程技术网

C++ VS2012静态库、控制台应用程序和clr程序上使用cryptopp的链接错误

C++ VS2012静态库、控制台应用程序和clr程序上使用cryptopp的链接错误,c++,visual-studio-2012,dll,static-libraries,crypto++,C++,Visual Studio 2012,Dll,Static Libraries,Crypto++,我在VS2012 C++上有以下项目结构: cryptopp:从cryptopp项目下载并生成 AccessLib:使用cryptopp函数的静态库构建 TestApp:一个使用AccessLib(和cryptolib)的Win32控制台应用程序 UserApp:具有CLR支持(/CLR)的Windows交互式应用程序,它间接使用AccessLib(和cryptolib) 嗯,我的第一次尝试是使这个解决方案能够工作,以构建我的控制台应用程序和windows应用程序。顺便说一句,cryptopp是

我在VS2012 C++上有以下项目结构:

cryptopp
:从cryptopp项目下载并生成

AccessLib
:使用cryptopp函数的静态库构建

TestApp
:一个使用AccessLib(和cryptolib)的Win32控制台应用程序

UserApp
:具有CLR支持(
/CLR
)的Windows交互式应用程序,它间接使用AccessLib(和cryptolib)

嗯,我的第一次尝试是使这个解决方案能够工作,以构建我的控制台应用程序和windows应用程序。顺便说一句,
cryptopp
是按照手册和规范中描述的方式构建的。cryptopp项目中的所有测试都在构建环境中正常运行

以下是我如何构建我的项目:

  • AccessLib
    设置为
    /Mtd
    /MT
    分别用于调试或发布,分别从
    cryptodir\Win32\Output\Debug
    cryptodir\Win32\Output\Release
    链接
    cryptolib.lib

  • TestApp
    设置为分别用于调试或发布的
    /MTd
    /MT
    ,链接到从上述步骤生成的
    AccessLib.lib

到目前为止还可以,但在构建
UserApp
时,它不能作为
TestApp
需要的
/clr
工作,这与
MTd
/MT
不兼容

因此,我的第一个问题是:我不能让一个CLR程序链接到一个静态库,而这个库具有
/MTd
/MT
。。。。我应该如何将我的
/clr
程序构建到我的静态库
AccessLib.lib
,该库也可以访问
cryptopp
?我是否需要将所有内容转换为DLL项目

我甚至尝试将cryptopp转换为DLL,这样:

  • AccessLib
    设置为
    /MDd
    /MD
    分别用于调试或发布,分别从
    cryptodir\Win32\DLL\u Output\Debug
    cryptodir\Win32\DLL\u Output\Release
    链接
    cryptolib.lib
该步骤进行得很顺利,但当尝试将
TestApp
构建为
/MDd
/MD
分别用于调试或发布时,链接到从上述步骤生成的
AccessLib.lib
,我遇到了如下错误:

 1>------ Build started: Project: TestApp, Configuration: Debug Win32 ------
1>cryptlib.lib(hrtimer.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in TestApp.obj
1>cryptlib.lib(pch.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in TestApp.obj
1>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in cryptlib.lib(hrtimer.obj)
1>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in cryptlib.lib(hrtimer.obj)
1>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in cryptlib.lib(hrtimer.obj)
1>msvcprtd.lib(MSVCP110D.dll) : error LNK2005: "public: __thiscall std::locale::id::id(unsigned int)" (??0id@locale@std@@QAE@I@Z) already defined in cryptlib.lib(pch.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: unsigned char * __thiscall CryptoPP::AllocatorWithCleanup<unsigned char,0>::allocate(unsigned int,void const *)" (?allocate@?$AllocatorWithCleanup@E$0A@@CryptoPP@@QAEPAEIPBX@Z) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: void __thiscall CryptoPP::AllocatorWithCleanup<unsigned char,0>::deallocate(void *,unsigned int)" (?deallocate@?$AllocatorWithCleanup@E$0A@@CryptoPP@@QAEXPAXI@Z) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: unsigned char * __thiscall CryptoPP::AllocatorWithCleanup<unsigned char,0>::reallocate(unsigned char *,unsigned int,unsigned int,bool)" (?reallocate@?$AllocatorWithCleanup@E$0A@@CryptoPP@@QAEPAEPAEII_N@Z) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: __thiscall CryptoPP::AllocatorWithCleanup<unsigned char,0>::AllocatorWithCleanup<unsigned char,0>(void)" (??0?$AllocatorWithCleanup@E$0A@@CryptoPP@@QAE@XZ) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: __thiscall CryptoPP::Rijndael::Enc::Enc(void)" (??0Enc@Rijndael@CryptoPP@@QAE@XZ) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: virtual __thiscall CryptoPP::Rijndael::Enc::~Enc(void)" (??1Enc@Rijndael@CryptoPP@@UAE@XZ) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: __thiscall CryptoPP::Rijndael::Enc::Enc(class CryptoPP::Rijndael::Enc const &)" (??0Enc@Rijndael@CryptoPP@@QAE@ABV012@@Z) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: static char const * __cdecl CryptoPP::CBC_ModeBase::StaticAlgorithmName(void)" (?StaticAlgorithmName@CBC_ModeBase@CryptoPP@@SAPBDXZ) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: __thiscall CryptoPP::CBC_Encryption::CBC_Encryption(void)" (??0CBC_Encryption@CryptoPP@@QAE@XZ) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: virtual __thiscall CryptoPP::CBC_Encryption::~CBC_Encryption(void)" (??1CBC_Encryption@CryptoPP@@UAE@XZ) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: virtual __thiscall CryptoPP::StreamTransformationFilter::~StreamTransformationFilter(void)" (??1StreamTransformationFilter@CryptoPP@@UAE@XZ) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: __thiscall CryptoPP::StringSinkTemplate<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::StringSinkTemplate<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (??0?$StringSinkTemplate@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@CryptoPP@@QAE@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: virtual __thiscall CryptoPP::StringSinkTemplate<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::~StringSinkTemplate<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??1?$StringSinkTemplate@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@CryptoPP@@UAE@XZ) already defined in accesslib.lib(Encryptor.obj)
1>cryptopp.lib(cryptopp.dll) : error LNK2005: "public: __thiscall CryptoPP::Exception::Exception(enum CryptoPP::Exception::ErrorType,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0Exception@CryptoPP@@QAE@W4ErrorType@01@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) already defined in accesslib.lib(Encryptor.obj)
1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>accesslib.lib(Encryptor.obj) : error LNK2001: unresolved external symbol "class CryptoPP::NameValuePairs const & const CryptoPP::g_nullNameValuePairs" (?g_nullNameValuePairs@CryptoPP@@3ABVNameValuePairs@1@B)
1>c:\project\dev\accesslib\Debug\TestApp.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
1>----构建已启动:项目:TestApp,配置:调试Win32------
1> cryptlib.lib(hrtimer.obj):错误LNK2038:检测到“RuntimeLibrary”不匹配:值“MTd\U StaticDebug”与TestApp.obj中的值“MDd\U DynamicDebug”不匹配
1> cryptlib.lib(pch.obj):错误LNK2038:检测到“RuntimeLibrary”不匹配:值“MTd\u StaticDebug”与TestApp.obj中的值“MDd\u DynamicDebug”不匹配
1> msvcprtd.lib(MSVCP110D.dll):错误LNK2005:“public:\u thiscall std::\u Container\u base12::\u Container\u base12(void)”(?0\u Container_base12@std@@QAE@XZ)已在cryptlib.lib(hrtimer.obj)中定义
1> msvcprtd.lib(MSVCP110D.dll):错误LNK2005:“public:\u thiscall std::\u Container\u base12::~\u Container\u base12(void)”(?1\u Container_base12@std@@QAE@XZ)已在cryptlib.lib(hrtimer.obj)中定义
1> msvcprtd.lib(MSVCP110D.dll):错误LNK2005:“public:void\u thiscall std::_Container\u base12::_Orphan\u all(void)”(?_Orphan_all@_Container_base12@std@@QAEXXZ)已在cryptlib.lib(hrtimer.obj)中定义
1> msvcprtd.lib(MSVCP110D.dll):错误LNK2005:“public:u thiscall std::locale::id::id(unsigned int)”(?)??0id@locale@性病@@QAE@I@Z) 已在cryptlib.lib(pch.obj)中定义
1> cryptopp.lib(cryptopp.dll):错误LNK2005:“public:unsigned char*u thiscall cryptopp::AllocatorWithCleanup::allocate(unsigned int,void const*)”(?allocate@$AllocatorWithCleanup@E$0A@@CryptoPP@@QAEPAEIPBX@Z)已在accesslib.lib(Encryptor.obj)中定义
1> cryptopp.lib(cryptopp.dll):错误LNK2005:“public:void\uu thiscall cryptopp::AllocatorWithCleanup::deallocate(void*,unsigned int)”(?deallocate@$AllocatorWithCleanup@E$0A@@CryptoPP@@QAEXPAXI@Z)已在accesslib.lib(Encryptor.obj)中定义
1> cryptopp.lib(cryptopp.dll):错误LNK2005:“public:unsigned char*u thiscall cryptopp::AllocatorWithCleanup::reallocation(unsigned char*,unsigned int,unsigned int,bool)”(?reallocation@$AllocatorWithCleanup@E$0A@@CryptoPP@@QAEPAEII_N@Z)已在accesslib.lib(Encryptor.obj)中定义
1> cryptopp.lib(cryptopp.dll):错误LNK2005:“public:u thiscall cryptopp::AllocatorWithCleanup::AllocatorWithCleanup(void)”(?0$AllocatorWithCleanup@E$0A@@CryptoPP@@QAE@XZ)已在accesslib.lib(Encryptor.obj)中定义
1> cryptopp.lib(cryptopp.dll):错误LNK2005:“public:u thiscall cryptopp::Rijndael::Enc::Enc(void)”(?)??0Enc@Rijndael@CryptoPP@@QAE@XZ)已在accesslib.lib(Encryptor.obj)中定义
1> cryptopp.lib(cryptopp.dll):错误LNK2005:“public:virtual u thiscall cryptopp::Rijndael::Enc:::~Enc(void)”(??1Enc@Rijndael@CryptoPP@@UAE@XZ)已在accesslib.lib(Encryptor.obj)中定义
1> cryptopp.lib(cryptopp.dll):错误LNK2005:“public:u thiscall cryptopp::Rijndael::Enc::Enc(类cryptopp::Rijndael::Enc const&)”(??0Enc@Rijndael@CryptoPP@@QAE@ABV012@@Z) 已在accesslib.lib(Encryptor.obj)中定义
1> cryptopp.lib(cryptopp.dll):错误LNK2005:“public:static char const*u cdecl cryptopp::CBC_ModeBase::StaticAlgorithmName(void)”(?StaticAlgorithmName@CBC_ModeBase@CryptoPP@@SAPBDXZ)已在accesslib.lib(Encryptor.obj)中定义
1> cryptopp.lib(cryptopp.dll):错误LNK2005:“public:\u thiscall cryptopp::CBC\u Encryption::CBC\u Encryption(void)”(??0CBC_Encryption@CryptoPP@@QAE@XZ)已在accesslib.lib(Encryptor.obj)中定义
1> cryptopp.lib(cryptopp.dll):错误LNK2005:“public:virtual\u thistcall cryptopp::CBC\u Encryption::~CBC\u Encryption(void)”(??1CBC_Encryption@CryptoPP@@UAE@XZ)已在accesslib.lib(Encryptor.obj)中定义
1> cryptopp.lib(cryptopp.dll):错误