2
votes

I'm trying to use MySQL with Visual Studio 2010. I've added the MySQL include directory:

C:\Program Files\MySQL\MySQL Server 5.5\include

...to the project properties under VC++ Directories -> Include Directories.

And added:

C:\Program Files\MySQL\MySQL Server 5.5\lib

&

C:\Program Files\MySQL\MySQL Server 5.5\lib\debug

...to VC++ Directories -> Library Directories.

It was working a couple of days ago, but has now stopped working with the following error:

fatal error LNK1120: 7 unresolved externals

Can anyone help, thanks.

UPDATE: Removed the C:\Program Files\MySQL\MySQL Server 5.5\lib\debug directory from the Include driectories and then added the following lib files to the Linker -> additional dependencies:

C:\Program Files\MySQL\MySQL Server 5.5\lib\mysqlclient.lib C:\Program Files\MySQL\MySQL Server 5.5\lib\libmysql.lib

This genertaes the following errors:

1>LIBCMT.lib(invarg.obj) : error LNK2005: __set_invalid_parameter_handler already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(dosmap.obj) : error LNK2005: __errno already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(file.obj) : error LNK2005: __iob_func already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj) 1>LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(winsig.obj) : error LNK2005: signal already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(crt0init.obj) : error LNK2005: __xi_a already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMT.lib(fflush.obj) : error LNK2005: _fflush already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(atox.obj) : error LNK2005: atoi already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(errmode.obj) : error LNK2005: __set_app_type already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(strtol.obj) : error LNK2005: _strtol already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(strtol.obj) : error LNK2005: _strtoul already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(strnicmp.obj) : error LNK2005: __strnicmp already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(osfinfo.obj) : error LNK2005: __get_osfhandle already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LIBCMT.lib(osfinfo.obj) : error LNK2005: __open_osfhandle already defined in MSVCRTD.lib(MSVCR100D.dll) 1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library 1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

1
What are the unresolved externals - please show the complete errormmmmmm
you have to specify the library names themselves as well under linker->additional dependencies (unless autolinking is used but that does not seem to be the case). Apart from that, it's not a good idea to give both lib and lib/debug subdirectories, pick one of them.stijn
thanks, I dropped the debug reference and added the additional dependencies but this gives me the errors show above (in the updated question).Columbo
classical case of mixing static/dynamic/release/debug libs. Not sure if this is due to mysql though (afaik it's statically linked so does not depend on any C runtime). See msdn.microsoft.com/en-us/library/abx4dbyh(v=VS.100).aspx for explanation: you are compiling with /MDd but somehow also linking against libcmt.stijn
Thanks, that's made it all start to make sense. MySQL stopped working when I installed Boost to try out threads and your link shows that the lib clashing is msvcrtd.lib which is concerned with multithreading. I was focused on MySQL, thanks.Columbo

1 Answers

0
votes

The problem here was that I was trying to use Visual Studio on my local PC to create and test C++ programs destined for a remote Linux system. I did this because I liked the VS debugging but it ended up causing more trouble that it's worth.

Instead I've now started using GDB over on the linux server and it is working well. It's a bit less GUI but it works.

The result is more time programming less time fiddling around with settings in drop down menus.