Database Lib Interfere


#1

Hey there

I’m currently trying to use the SOCI library to connect to a MySQL database to issue sql commands. However I’m having quite a bit of difficulty trying to get it working with JUCE.

Everything compiles, but when Visual Studio gets to the linking phase it throws errors. For instance if I have the header files as follows:

#include “soci.h”
#include “soci-mysql.h”
#include <juce.h>

I get the following linker problems:

[quote]JUCE! Library to link to: jucelib_static_Win32_debug.lib
Linking…
msvcprt.lib(MSVCP80.dll) : error LNK2005: “public: __thiscall std::basic_string<char,struct std::char_traits,class std::allocator >::basic_string<char,struct std::char_traits,class std::allocator >(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)” (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in libcpmtd.lib(string.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: “public: __thiscall std::basic_string<char,struct std::char_traits,class std::allocator >::~basic_string<char,struct std::char_traits,class std::allocator >(void)” (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in DatabaseConnector.obj
msvcprt.lib(MSVCP80.dll) : error LNK2005: “public: __thiscall std::basic_string<char,struct std::char_traits,class std::allocator >::basic_string<char,struct std::char_traits,class std::allocator >(char const *)” (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in DatabaseConnector.obj
MSVCRT.lib(MSVCR80.dll) : error LNK2005: “public: __thiscall std::exception::exception(char const * const &)” (??0exception@std@@QAE@ABQBD@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR80.dll) : error LNK2005: “public: virtual __thiscall std::exception::~exception(void)” (??1exception@std@@UAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR80.dll) : error LNK2005: “public: __thiscall std::exception::exception(void)” (??0exception@std@@QAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR80.dll) : error LNK2005: “public: __thiscall std::exception::exception(class std::exception const &)” (??0exception@std@@QAE@ABV01@@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR80.dll) : error LNK2005: _memmove_s already defined in LIBCMTD.lib(memmove_s.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: __thiscall type_info::type_info(class type_info const &)” (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: class type_info & __thiscall type_info::operator=(class type_info const &)” (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
LINK : warning LNK4098: defaultlib ‘MSVCRT’ conflicts with use of other libs; use /NODEFAULTLIB:library
DatabaseConnector.obj : error LNK2001: unresolved external symbol “struct SOCI::MySQLBackEndFactory const SOCI::mysql” (?mysql@SOCI@@3UMySQLBackEndFactory@1@B)
.\Debug/newsapp.exe : fatal error LNK1120: 1 unresolved externals
[/quote]

So I thought that maybe the juce header needs to be included first, so I swapped them around and I get these errors:

[quote]c:\soci-2.2.0\src\core\soci.h(530) : warning C4003: not enough actual parameters for macro 'T’
c:\soci-2.2.0\src\core\soci.h(530) : warning C4003: not enough actual parameters for macro 'JUCE_T’
c:\soci-2.2.0\src\core\soci.h(2099) : warning C4003: not enough actual parameters for macro 'T’
c:\soci-2.2.0\src\core\soci.h(2099) : warning C4003: not enough actual parameters for macro 'JUCE_T’
c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(894) : error C2988: unrecognizable template declaration/definition
c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(894) : error C2059: syntax error : '('
c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(894) : error C2090: function returns array
c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(894) : error C2988: unrecognizable template declaration/definition
c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(894) : error C2059: syntax error : ')'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(1454) : error C2143: syntax error : missing ‘;’ before '*'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(2938) : error C2143: syntax error : missing ‘;’ before 'identifier’
c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(2938) : warning C4091: 'typedef ’ : ignored on left of ‘_FLOATING_SAVE_AREA’ when no variable is declared
c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(2938) : fatal error C1075: end of file found before the left brace ‘{’ at ‘c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h(22)’ was matched
[/quote]

Is there a problem regarding JUCE? Is there an issue with SOCI?

Otherwise can anyone recommend any other library I can use to interact with a database? (tried Mysql++ and couldnt get it to work either)

Thanks SO much for the help.


#2

Not sure what’s going wrong in the first case, but in the second one, you’re just having trouble with juce’s T macro - have a search through the code for the JUCE_DONT_DEFINE_MACROS setting, which I added to help with that kind of thing.


#3

Cool for the juce_WithoutMacros file.

So I now include the juce_WithoutMacros.h file instead of juce.h and I get the following linker errors:

[quote]Linking…
msvcprt.lib(MSVCP80.dll) : error LNK2005: “public: __thiscall std::basic_string<char,struct std::char_traits,class std::allocator >::basic_string<char,struct std::char_traits,class std::allocator >(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)” (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in libcpmtd.lib(string.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: “public: __thiscall std::basic_string<char,struct std::char_traits,class std::allocator >::~basic_string<char,struct std::char_traits,class std::allocator >(void)” (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in DatabaseConnector.obj
msvcprt.lib(MSVCP80.dll) : error LNK2005: “public: __thiscall std::basic_string<char,struct std::char_traits,class std::allocator >::basic_string<char,struct std::char_traits,class std::allocator >(char const *)” (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in DatabaseConnector.obj
MSVCRT.lib(MSVCR80.dll) : error LNK2005: “public: __thiscall std::exception::exception(char const * const &)” (??0exception@std@@QAE@ABQBD@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR80.dll) : error LNK2005: “public: virtual __thiscall std::exception::~exception(void)” (??1exception@std@@UAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR80.dll) : error LNK2005: “public: __thiscall std::exception::exception(void)” (??0exception@std@@QAE@XZ) already defined in LIBCMTD.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR80.dll) : error LNK2005: “public: __thiscall std::exception::exception(class std::exception const &)” (??0exception@std@@QAE@ABV01@@Z) already defined in LIBCMTD.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR80.dll) : error LNK2005: _memmove_s already defined in LIBCMTD.lib(memmove_s.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: __thiscall type_info::type_info(class type_info const &)” (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: “private: class type_info & __thiscall type_info::operator=(class type_info const &)” (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
LINK : warning LNK4098: defaultlib ‘MSVCRT’ conflicts with use of other libs; use /NODEFAULTLIB:library
DatabaseConnector.obj : error LNK2001: unresolved external symbol “struct SOCI::MySQLBackEndFactory const SOCI::mysql” (?mysql@SOCI@@3UMySQLBackEndFactory@1@B)
.\Debug/newsapp.exe : fatal error LNK1120: 1 unresolved externals
[/quote]

To me it looks like things are conflicting with MSVCRT or something. Things seem to already be defined in one place and then again in another. I cannot follow the compiler’s instructions and use the /NODEFAULTLIB:library as then I get millions of errors as I presume JUCE relies on many default libraries.

Any ideas?


#4

MySQL require you build against a different C library than default lib…
In the C library setting off your solution, please select the same C library for
each project.

Because you won’t be able to build mysql without multithreaded C library (either Multithreaded or Debug Multithreaded), I suggest you set the same for Juce.

The compiler options should be /MT or /MTd for both project (if using VS6.0)


#5

What the SOCI library lets you do is either compile a LIB or DLL. I was using the lib project, and it just wasn’t working. So I tried the DLL project and I now get the following link error:

[quote]DatabaseConnector.obj : error LNK2001: unresolved external symbol “struct SOCI::MySQLBackEndFactory const SOCI::mysql” (?mysql@SOCI@@3UMySQLBackEndFactory@1@B)
.\Debug/newsapp.exe : fatal error LNK1120: 1 unresolved externals[/quote]

I’ve tried everything to remove that and I cannot.

Can someone not recommend another database library I could use instead? This is frustrating, where it should be so simple.


#6

Anyway, mysql++ library is the best MySql C++ wrapper class library I’ve ever tested :slight_smile: You can obtain it here http://tangentsoft.net/mysql++/


#7