Multiple problems linking mysqlpp_d.lib - c++

Today I added a class which manages the connection to a MySQL Server. It will be multi-threaded, so I want to use mysql++. I downloaded the newest version and compiled it in debug mode without any errors. Once I added the compiled mysqlpp_d.lib to my solutions, and of course the other requirements too (mysql 5.0 include and lib), I got some linker errors.
Error 17 error LNK1169: one or more multiply defined symbols found C:\Users\root\Documents\Visual Studio 2010\Projects\C++\xxxx\binaries\xxxx.exe 1 1 xxxxx
Error 16 error LNK2005: "public: __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >(int)" (??0?$basic_ostringstream#DU?$char_traits#D#std##V?$allocator#D#2##std##QAE#H#Z) already defined in xxxxxx.obj C:\Users\root\Documents\Visual Studio 2010\Projects\C++\xxxx\trunk\vc10\xxxxx\mysqlpp_d.lib(mysqlpp_d.dll) xxxxxxx
Error 15 error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::str(void)const " (?str#?$basic_ostringstream#DU?$char_traits#D#std##V?$allocator#D#2##std##QBE?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##2#XZ) already defined in client_context.obj C:\Users\root\Documents\Visual Studio 2010\Projects\C++\xxx\trunk\vc10\xxx\mysqlpp_d.lib(mysqlpp_d.dll) xxxxx
Error 14 error LNK2005: "public: void __thiscall std::basic_ostringstream<char,struct std::char_traits<char>,class std::allocator<char> >::`vbase destructor'(void)" (??_D?$basic_ostringstream#DU?$char_traits#D#std##V?$allocator#D#2##std##QAEXXZ) already defined in xxxxx.obj C:\Users\root\Documents\Visual Studio 2010\Projects\C++\xxx\trunk\vc10\xxxx\mysqlpp_d.lib(mysqlpp_d.dll) xxx
Is there a solution for these errors?
BTW: I compiled the whole mysql++ libary without changing any compile configurations.

Define MYSQLPP_NO_DLL in Project Properties->C/C++/Preprocessor

Try setting /NODEFAULTLIB parameter in project options -> Linker/Input

Related

Crypto++ library link error using Visual Studio 2017

I'm trying to use the Crypto++ librairy in my project (windows application). Using it, include, compilation work fine, but impossible to deal with the link error
Here is some exemple of link errors, there is more, but don't think it's revelant to copy paste all of them
error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CryptoV2::encrypt(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?encrypt#CryptoV2##SA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V23##Z) referenced in function "public: void __thiscall PStore::storeReversibleCrypt(wchar_t *,char *)" (?storeReversibleCrypt#PStore##QAEXPA_WPAD#Z)
error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CryptoV2::hashPassword(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> >)" (?hashPassword#CryptoV2##SA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V23#0#Z)
fatal error LNK1120: 4 unresolved externals
Basically, I add the "Win32\Output\Release" directory of crypto++ to my linker's additionnal library directories properties, and also the main folder to my C/C++'s General's property "Additional Include Directories"
I've tried a lot of thinks, like adding the library as a new project (same errors), adding all cpp files to my project and compiling with it (not compiling), adding only .cpp files I was using (not realistic, too much), linking all different folder of the cryptopp610 releases (cryptdll, cryptlib, dll_output, Output, same errors), and now, I don't really know what more I can try. I makre also a lots of search, trying all solution I saw (don't remember all of them), still the same problems. I also try to create a new project to add crypto++ without long compilation or mysterious problem, but I also get linker error.
Do anyone got any advice to help me ? Anyway, thank's a lot, and pardon my English
EDIT: Need to add that on the new blank project, I get 63 unresolved external symbol, so I think I forgot to do some basic stuff, but can't figure out which
error LNK2019: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CryptoV2::encrypt(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?encrypt#CryptoV2##SA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V23##Z) referenced in function "public: void __thiscall PStore::storeReversibleCrypt(wchar_t *,char *)" (?storeReversibleCrypt#PStore##QAEXPA_WPAD#Z)
error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl CryptoV2::hashPassword(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> >)" (?hashPassword#CryptoV2##SA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V23#0#Z)
The missing symbols are not from Crypto++. Crypto++ uses the CryptoPP namespace. The missing symbols are from the CryptoV2 namespace or class. I'm guessing that's another crypto library.
You were right in adding directories and a library to the linker settings. However, you need to do it for the CryptoV2 library (in addition to the Crypto++ library).
For completeness, it looks like these are missing:
std::string CryptoV2::encrypt(std::string);
std::string CryptoV2::hashPassword(std::string, std::string);
It could be Ws2_32.lib there is missing from the linker
add #include "dll.h" like stated in the Readme:
To use the Crypto++ DLL in your application, #include "dll.h" before including any other Crypto++ header files, and place the DLL in the same directory as your .exe file. dll.h includes the line #pragma comment(lib, "cryptopp") so you don't have to explicitly list the import library in your project settings.
https://github.com/weidai11/cryptopp/blob/master/Readme.txt#L136

Errors on running a sample PCL code on Visual Studio 2017

I'm trying to run a sample PCL code just to start developing PCL on Visual Studio (2017) on my Windows 10. I followed the guides here: http://dominoc925.blogspot.com/2016/07/set-up-visual-studio-to-use-all-in-one.html
As suggested in their blog post, I downloaded the all-in-one 64bit installer from here: https://github.com/PointCloudLibrary/pcl/releases/tag/pcl-1.8.1rc1
While I followed all steps, they didn't have a link to a property sheet for PCL 1.8.1 (where can I find it?)
Anyways, when I try to compile my project (no errors on editor), I get 3 link errors as below. How can I run a sample PCL code in Visual Studio? Please help.
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "void __cdecl pcl::console::print(enum pcl::console::VERBOSITY_LEVEL,char const *,...)" (?print#console#pcl##YAXW4VERBOSITY_LEVEL#12#PEBDZZ) referenced in function "public: void __cdecl pcl::detail::FieldMapper<struct pcl::PointXYZ>::operator()<struct pcl::fields::x>(void)" (??$?RUx#fields#pcl###?$FieldMapper#UPointXYZ#pcl###detail#pcl##QEAAXXZ) PCLViewer c:\Users\xxx\documents\visual studio 2017\Projects\PCLViewer\PCLViewer\Source.obj 1
Error LNK2001 unresolved external symbol "public: virtual int __cdecl pcl::PLYReader::readHeader(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct pcl::PCLPointCloud2 &,class Eigen::Matrix<float,4,1,0,4,1> &,class Eigen::Quaternion<float,0> &,int &,int &,unsigned int &,int)" (?readHeader#PLYReader#pcl##UEAAHAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEAUPCLPointCloud2#2#AEAV?$Matrix#M$03$00$0A#$03$00#Eigen##AEAV?$Quaternion#M$0A##7#AEAH4AEAIH#Z) PCLViewer c:\Users\xxx\documents\visual studio 2017\Projects\PCLViewer\PCLViewer\Source.obj 1
Error LNK2001 unresolved external symbol "public: virtual int __cdecl pcl::PLYReader::read(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct pcl::PCLPointCloud2 &,class Eigen::Matrix<float,4,1,0,4,1> &,class Eigen::Quaternion<float,0> &,int &,int)" (?read#PLYReader#pcl##UEAAHAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEAUPCLPointCloud2#2#AEAV?$Matrix#M$03$00$0A#$03$00#Eigen##AEAV?$Quaternion#M$0A##7#AEAHH#Z) PCLViewer c:\Users\xxx\documents\visual studio 2017\Projects\PCLViewer\PCLViewer\Source.obj 1
Error LNK1120 3 unresolved externals PCLViewer c:\users\xxx\documents\visual studio 2017\Projects\PCLViewer\x64\Debug\PCLViewer.exe 1

Boost-log linker error

i've downloaded and builded Boost 1.55 from source. I'm trying to use Boost-log. In basic case (http://boost-log.sourceforge.net/libs/log/doc/html)/log/tutorial.html#log.tutorial.trivial it's working fine without any problems, but when i try to use some more advanced features(like this - http://boost-log.sourceforge.net/libs/log/example/doc/tutorial_fmt_stream.cpp ) i'm getting this error:
main.obj : error LNK2019: unresolved external symbol "void __cdecl
boost::filesystem::path_traits::convert(char const *,char const
*,class std::basic_string,class std::allocator>
&,class std::codecvt const &)" (?convert#path_traits#filesystem#boost##YAXPBD0AAV?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##std##ABV?$codecvt#GDH#5##Z)
referenced in function "void __cdecl
boost::filesystem::path_traits::dispatch,class std::allocator > >(class
std::basic_string,class
std::allocator > const &,class std::basic_string,class
std::allocator > &,class std::codecvt const &)"
(??$dispatch#V?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##std###path_traits#filesystem#boost##YAXABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AAV?$basic_string#GU?$char_traits#G#std##V?$allocator#G#2##4#ABV?$codecvt#GDH#4##Z)
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl
boost::log::v2s_mt_nt5::aux::code_convert(unsigned short const
*,unsigned int,class std::basic_string,class std::allocator > &,class
std::locale const &)"
(?code_convert#aux#v2s_mt_nt5#log#boost##YAXPBGIAAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##ABVlocale#6##Z)
referenced in function "private: void __thiscall
boost::log::v2s_mt_nt5::basic_formatting_ostream,class std::allocator>
::aligned_write(unsigned short const *,__int64)" (??$aligned_write#G#?$basic_formatting_ostream#DU?$char_traits#D#std##V?$allocator#D#2##v2s_mt_nt5#log#boost##AAEXPBG_J#Z)
1>main.obj : error LNK2019: unresolved external symbol "public: static
class std::codecvt const & __cdecl
boost::filesystem::path::codecvt(void)"
(?codecvt#path#filesystem#boost##SAABV?$codecvt#GDH#std##XZ)
referenced in function "public: __thiscall
boost::filesystem::path::path(char const (&)[14],void
*)" (??$?0$$BY0O#$$CBD#path#filesystem#boost##QAE#AAY0O#$$CBDPAX#Z)
So basically it can't find functions convert(...), code_convert(...) and codecvt(...) in .lib files.
I've already tried to add all release libraries (.lib files made while building boost) to "additional libraries" and generally i think that visual studio find all libraries, but can't find those functions in libraries. Any ideas how can i fix this?
I've build Boost 1.55 from source using visual studio 2010 (msvc10.0), 32 bit, release and debug. I'm working on windows 7 x64.
I had the same problem and I could fix it by changing one of the Project properties on VisualStudio 2010.
Go to:
Property Pages -> ConfigurationProperties -> C/C++ -> Language -> Treat WChar_t As Built in Type:
And set the property to:
Yes (/Zc:wchar_t)
I hope it will be helpful for you too :)
Take care,

LNK2005 (already defined)

I know you've seen 21728517 people asking for help with this one but after searching and reading about this I really can't figure this one out. I know this error, I've seen it before, however, this time, I can't seem to get around it.
I've also tried this checklist.
So, the errors:
Error 25 error LNK2005: "void __cdecl checkStatus(unsigned int &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,bool)" (?checkStatus##YAXAAIV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##_N#Z) already defined in DollarRecognizer.obj C:\Users\Rui Teixeira\Desktop\Current\Tese\SVN\TIFEE_Empty\TIFEE_Empty\main.obj TIFEE_Empty
Error 26 error LNK2005: "void __cdecl depth2rgb(unsigned short const *,unsigned short *,char *,int,int)" (?depth2rgb##YAXPBGPAGPADHH#Z) already defined in DollarRecognizer.obj C:\Users\Rui Teixeira\Desktop\Current\Tese\SVN\TIFEE_Empty\TIFEE_Empty\main.obj TIFEE_Empty
Error 27 error LNK2005: "class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > __cdecl explode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,char)" (?explode##YA?AV?$vector#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##V?$allocator#V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###2##std##V?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##2#D#Z) already defined in DollarRecognizer.obj C:\Users\Rui Teixeira\Desktop\Current\Tese\SVN\TIFEE_Empty\TIFEE_Empty\main.obj TIFEE_Empty
So, the thing is, these are functions defined in "misc.h" with the proper #ifndef #define #endif. They are not defined elsewhere but I still get the LNK2005 of death. What am I doing wrong?
Thanks in advance.
Define the functions in misc.cpp, rather than in misc.h.
The problem is probably due to #includeing misc.h in multiple CPP files. the header guards prevent a header from being included multiple times in the same translation unit, but each CPP file is (typically) a separate translation unit. So those functions end up getting defined twice -- once in each translation unit.

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.