Link errors using cryptopp on VS2012 static library, console application and clr program - c++

I have the following project structure on VS2012 C++:
cryptopp: As downloaded and build from cryptopp project.
AccessLib: A static library build using cryptopp functions.
TestApp: A Win32 console application that uses AccessLib (and cryptolib indirectly)
UserApp: A Windows interactive application with CLR support (/clr) that uses AccessLib (and cryptolib indirectly)
Well, my first try was to make this solution work to build my console application and my windows application. BTW, cryptopp was build in a way described in manuals and this SO link. All tests from cryptopp project are running fine in the build environment.
Here is how I´ve build my project:
Set AccessLib as being /Mtd or /MT for Debug or Release respectively, linking with cryptolib.lib from cryptodir\Win32\Output\Debug and cryptodir\Win32\Output\Releaserespectively.
Set TestApp as being also /MTd or /MT for Debug or Release respectively, linking to AccessLib.lib generated from step above.
Fine till now, but when building UserAppit does not work as TestApp needs /clr and that´s incompatible with MTdor /MT.
So, here goes my first question: I can´t have a CLR program that links to a static library that has /MTdor /MT.... What should I do to build my /clr program to my static library AccessLib.lib that access cryptopp as a static library also ? Should I need to convert everything to DLL project ?
Well, I even tried to convert to use cryptopp as a DLL, that way:
Set AccessLib as being /MDd or /MD for Debug or Release respectively, linking with cryptolib.lib from cryptodir\Win32\DLL_Output\Debug and cryptodir\Win32\DLL_Output\Releaserespectively.
That step went fine, but when trying to build TestApp as being also /MDd or /MD for Debug or Release respectively, linking to AccessLib.lib generated from step above, I got several errors like:
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 ==========
I did not move to build UserApp with that configuration.
Help is appreciated to make this whole thing work together. I want to avoid usage of DLL´s at all. My original idea is to have everything as static libraries, but I don´t know if I can achieve that on that solution configuration.
Help appreciated.

You can not link a library compiled with MT or MTd to a program complied with MD or MDd. They have different CRT library.
You can rebuild cryptopp with MD or MDd

That step went fine, but when trying to build TestApp as being also /MDd or /MD for Debug or Release respectively, linking to AccessLib.lib generated from step above, I got several errors like...
You are mixing and matching runtimes. You should probably change Crypto++ and make it use dynamic runtime linking the the C/C++ runtime library. See Visual Studio | Dynamic Runtime Linking on the Crypto++ wiki.
I want to avoid usage of DLL´s at all. My original idea is to have everything as static libraries, but I don´t know if I can achieve that on that solution configuration.
Yes, this is preferred. It will work, but you need to build the Crypto++ static library using dynamic runtime linking. The project you want is cryptlib, and its output is found in <crypto++ dir>/Output/{Debug|Release}/{Win32|x64}. See the previous links.
You should also avoid the FIPS DLL. The DLL project is cryptdll, and its output is found in <crypto++ dir>/DLL_Output/.... The DLL is special purpose, and it only provides FIPS algorithms. Its not a general purpose DLL, it lacks most stuff you need, and it causes a lot of pain and misery.
I even go so far as to tell people to completely delete the cryptdll and dlltest projects because they cause so much trouble. Also see FIPS DLL on the Crypto++ wiki.
Link errors using cryptopp on VS2012 static library, console application and clr program
This is noteworthy... Crypto++ does not use the /clr option. You will need to modify the static library project settings and add it.
The static library's project is called cryptlib. You will need to do it for Win32 Debug, Win32 Release, x64 Debug and x64 Release.

Related

LNK2005 error when linking multiple projects that use boost

I have a project that consists from one main project, 3 projects that use boost and few other projects that links to static libraries. These 3 projects use boost. But I can't build my main project. I've got a lot of error LNK2005: .... already defined in ...
errors. As I understood, boost automaticaly links libraries to both of this projects. I tried to use BOOST_ALL_NO_LIB, but it didn't work. After adding this macro I've got unresolved symbols errors, but the redefinition errors still here. How can I solve this problem?
UPD1: there about 400+ errors. Here are first of them:
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "unsigned long __cdecl boost::asio::detail::win_tss_ptr_create(void)" (?win_tss_ptr_create#detail#asio#boost##YAKXZ) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "void __cdecl boost::asio::detail::do_throw_error(class boost::system::error_code const &,char const *)" (?do_throw_error#detail#asio#boost##YAXABVerror_code#system#3#PBD#Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "class boost::system::error_category const & __cdecl boost::asio::error::get_misc_category(void)" (?get_misc_category#error#asio#boost##YAABVerror_category#system#3#XZ) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::startup(struct boost::asio::detail::winsock_init_base::data &,unsigned char,unsigned char)" (?startup#winsock_init_base#detail#asio#boost##KAXAAUdata#1234#EE#Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::cleanup(struct boost::asio::detail::winsock_init_base::data &)" (?cleanup#winsock_init_base#detail#asio#boost##KAXAAUdata#1234##Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::throw_on_error(struct boost::asio::detail::winsock_init_base::data &)" (?throw_on_error#winsock_init_base#detail#asio#boost##KAXAAUdata#1234##Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "public: void __thiscall boost::asio::detail::win_iocp_io_service::post_deferred_completions(class boost::asio::detail::op_queue<class boost::asio::detail::win_iocp_operation> &)" (?post_deferred_completions#win_iocp_io_service#detail#asio#boost##QAEXAAV?$op_queue#Vwin_iocp_operation#detail#asio#boost###234##Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "struct boost::asio::detail::signal_state * __cdecl boost::asio::detail::get_signal_state(void)" (?get_signal_state#detail#asio#boost##YAPAUsignal_state#123#XZ) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: _boost_asio_signal_handler already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "public: static void __cdecl boost::asio::detail::signal_set_service::deliver_signal(int)" (?deliver_signal#signal_set_service#detail#asio#boost##SAXH#Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(Some_file.obj) : error LNK2005: "unsigned long __cdecl boost::asio::detail::win_tss_ptr_create(void)" (?win_tss_ptr_create#detail#asio#boost##YAKXZ) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(Some_file.obj) : error LNK2005: "void __cdecl boost::asio::detail::do_throw_error(class boost::system::error_code const &,char const *)" (?do_throw_error#detail#asio#boost##YAXABVerror_code#system#3#PBD#Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(Some_file.obj) : error LNK2005: "class boost::system::error_category const & __cdecl boost::asio::error::get_misc_category(void)" (?get_misc_category#error#asio#boost##YAABVerror_category#system#3#XZ) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(Some_file.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::startup(struct boost::asio::detail::winsock_init_base::data &,unsigned char,unsigned char)" (?startup#winsock_init_base#detail#asio#boost##KAXAAUdata#1234#EE#Z) already defined in Project_with_boost_2.lib(asio.obj)
UPD2: I also tried to use macros kind of BOOST_SYSTEM_NO_LIB, BOOST_ASIO_NO_LIB. Result is the same as by using BOOST_ALL_NO_LIB
UPD3: I can set linker option in my main project "Force File Output" to "Multiply Defined Symbols Only /FORCE:MULTIPLE" and project compiles successfully, but during execution it crashes, so I can't use this option.
Your issues have nothing to do with auto linking. The issue is the fact that you've imported boost::asio, a header only library that has some global state, into two separate binaries and linked them together (probably one or more dlls and an exe).
By doing this, you're creating more than one definition of these objects/functions, hence the LNK2005 errors. A bit on that in this post. You need to follow what the manual says about this situation, and build properly. From the docs:
Optional separate compilation
By default, Boost.Asio is a header-only library. However, some
developers may prefer to build Boost.Asio using separately compiled
source code. To do this, add #include <boost/asio/impl/src.hpp> to one
(and only one) source file in a program, then build the program with
BOOST_ASIO_SEPARATE_COMPILATION defined in the project/compiler
settings. Alternatively, BOOST_ASIO_DYN_LINK may be defined to build a
separately-compiled Boost.Asio as part of a shared library.
Emphasis mine. Make sure you define BOOST_ASIO_SEPARATE_COMPILATION is all associated projects that include boost::asio. About the /FORCE:MULTIPLE option, pretend this flag doesn't exist. It's evil, as you can see. It's throwing errors in the garbage that were there to tell you that something is seriously wrong.

Mixing native C++ and C++/CLI

I have a solution which consists of a native C++ DLL and a C++/CLI wrapper. My aim is to create a wrapper in C++/CLI of the native C++ DLL.
Whenever I try to create an instance of a native C++ class within the wrapper, I am met with many linker errors (see below).
2> .NETFramework,Version=v4.0.AssemblyAttributes.cpp
2>NFileOperation.obj : error LNK2028: unresolved token (0A000208) "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?FileExists#CFileOperation##$$FSA_NABV?$CStringT#_WV?$StrTraitATL#_WV?$ChTraitsCRT#_W#ATL###ATL###ATL###Z) referenced in function "[T2M] void __clrcall `dynamic initializer for 'public: static float * tagVARIANT::* ATL::CVarTypeInfo<float *>::pmField''(void)" (__t2m#???__E?pmField#?$CVarTypeInfo#PAM#ATL##2QQtagVARIANT##PAMQ3###YMXXZ#?A0x22b777aa##YMXXZ)
2>DeskUpdateManaged.obj : error LNK2028: unresolved token (0A00021C) "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?FileExists#CFileOperation##$$FSA_NABV?$CStringT#_WV?$StrTraitATL#_WV?$ChTraitsCRT#_W#ATL###ATL###ATL###Z) referenced in function "public: bool __clrcall DeskUpdateManaged::Conversion::FileExist(class System::String ^)" (?FileExist#Conversion#DeskUpdateManaged##$$FQ$AAM_NP$AAVString#System###Z)
2>DeskUpdateManaged.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?FileExists#CFileOperation##$$FSA_NABV?$CStringT#_WV?$StrTraitATL#_WV?$ChTraitsCRT#_W#ATL###ATL###ATL###Z) referenced in function "public: bool __clrcall DeskUpdateManaged::Conversion::FileExist(class System::String ^)" (?FileExist#Conversion#DeskUpdateManaged##$$FQ$AAM_NP$AAVString#System###Z)
2>NFileOperation.obj : error LNK2001: unresolved external symbol "public: static bool __cdecl CFileOperation::FileExists(class ATL::CStringT<wchar_t,class ATL::StrTraitATL<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?FileExists#CFileOperation##$$FSA_NABV?$CStringT#_WV?$StrTraitATL#_WV?$ChTraitsCRT#_W#ATL###ATL###ATL###Z)
2>C:\Users\ABGZAMANK\Music\DeskUpdate\Dev\Source\Solution\Debug\DeskUpdateManaged.dll : fatal error LNK1120: 3 unresolved externals
Function call within the C++/CLI to the native C++ DLL:
bool NFileOperation::FileExists(CAtlString sPathName)
{
return CFileOperation::FileExists(sPathName);
}
Is there a more adequate approach to what I am trying to achieve?
Any advice relating to the issue is much appreciated.
It seems that your native C++ code is using ATL/MFC. Assuming you are compiling under VS, go to the C++/CLI project's project properties->Configuration properties->General and select "Use of MFC" and "Use of ATL" to be either static library or shared dll (depending on your project type). This flag will add the necessary include paths, linking paths and libs to your project to make use of ATL/MFC types from within your project. Also, make sure that you are linking your C++/CLI project against your native C++ project to avoid linking errors from your project (easily found in the Linker segment of the project properties in General and Input).

linking error with CMake and Visual Studio 2010

I'm trying to compile osgearth library with VS2010. The library uses CMake, so after setting all dependencies it generates a VS2010 solution file. However when running build in VS I get this linker error (and 200 similar ones)
Error 7 error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::basic_ofstream >::`vbase destructor'(void)" (_imp??_D?$basic_ofstream#DU?$char_traits#D#std###std##QAEXXZ) referenced in function "public: virtual void __thiscall osgEarth::DiskCache::setImage(class osgEarth::TileKey const &,struct osgEarth::CacheSpec const &,class osg::Image const *)" (?setImage#DiskCache#osgEarth##UAEXABVTileKey#2#ABUCacheSpec#2#PBVImage#osg###Z) C:\swproj\osgearth-src\src\osgEarth\Caching.obj osgEarth
I'm not very familiar with C++, is there anything else I have to set up?
You're missing a reference to std::ofstream. You either need an #include in one of your files or a reference to the standard library dll in your project.

Linking error while using Visual Studio 2005(VC8)

I am getting a bunch of linking errors while trying to link the release version of an executable(debug version does not have the same issue). Comparing the command line for the link does not reveal any issues.
there are broadly 2 types of errors neither of which I can get a handle on.
The first kind complains about a unresolved external symbol _declspec(dllimport)
As an example:
error LNK2019: unresolved external symbol
"_declspec(dllimport)
public: __thiscall
stlpd_std::basic_string,class stlpd_std::allocator >::basic_string,class stlpd_std::allocator >(class stlpd_std::basic_string,class stlpd_std::allocator > const &)" (_imp??0?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std##QAE#ABV01##Z) referenced in function "public: __thiscall Springfield::generic::runtime_error::runtime_error(class stlpd_std::basic_string,class stlpd_std::allocator > const &)" (??0runtime_error#generic#Springfield##QAE#ABV?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std###Z)
for a more human readable version(replacing all the strings):
error LNK2019: unresolved external symbol
"__declspec(dllimport)
public: __thiscall
string::basic_string,class stlpd_std::allocator >(class string const &)" (_imp??0?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std##QAE#ABV01##Z) referenced in function "public: __thiscall Springfield::generic::runtime_error::runtime_error(class string const &)" (??0runtime_error#generic#Springfield##QAE#ABV?$basic_string#DV?$char_traits#D#stlpd_std##V?$allocator#D#2##stlpd_std###Z
The sceond class of errors complains about
unresolved external symbol __CrtDbgReportW
I hope I can get some kind of insight in dealing with this.
From the errors it looks like you are not including the CRT as one of your linked libraries. Here is a link to the different CRT lib's offered in Visual Studio 2005. Choose the one which is most appropriate and make sure it's in the list of lib's to link against
http://msdn.microsoft.com/en-us/library/abx4dbyh(VS.80).aspx
It looks like you're either including a file that's been built using the debug settings or you're mixing runtime libraries (DLL and static).

LNK2001 error when compiling windows forms application with VC++ 2008

I've been trying to write a small application which will work with mysql in C++. I am using MySQL server 5.1.41 and MySQL C++ connector 1.0.5. Everything compiles fine when i write console applications, but when i try to compile windows forms application exactly the same way (same libraries, same paths, same project properties) i get this errors:
Error 1 error LNK2001: unresolved external symbol "public: virtual int __clrcall sql::mysql::MySQL_Savepoint::getSavepointId(void)" (?getSavepointId#MySQL_Savepoint#mysql#sql##$$FUAMHXZ) test1.obj test1
Error 2 error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __clrcall sql::mysql::MySQL_Savepoint::getSavepointName(void)" (?getSavepointName#MySQL_Savepoint#mysql#sql##$$FUAM?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##XZ) test1.obj test1
following instructions from here, i've got this:
Undecoration of :- "?getSavepointId#MySQL_Savepoint#mysql#sql##UEAAHXZ"
is :- "public: virtual int __cdecl sql::mysql::MySQL_Savepoint::getSavepointId(void) __ptr64"
Undecoration of :- "?getSavepointName#MySQL_Savepoint#mysql#sql##UEAA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##XZ"
is :- "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl sql::mysql::MySQL_Savepoint::getSavepointName(void) __ptr64"
but what should i do now?
Project + Properties, General, change Common Language Runtime support to /clr from /clr:pure
Looks like an issue with calling conventions. I am not very familiar with managed C++, but this might help you.