Note that there are some explanatory texts on larger screens.

plurals
  1. POVisual Studio 2010 - Linking MySQL
    text
    copied!<p>I gave myself a project to get familiar with Windows Programming and Visual Studio. I am having trouble linking to the MySQL libraries so that I can use it in my project. I keep getting a LNK2019 error, which most likely means that I am not linking the .lib files properly. I've already set its configuration to include the include directories and library directories. (I also tried different combinations of setting VC++ Directories and C/C++ / Linker.)</p> <pre><code>Error 1 error LNK2019: unresolved external symbol _mysql_real_connect@32 referenced in function "public: void __thiscall Database::connect_db(void)" (?connect_db@Database@@QAEXXZ) D:\Media\Documents\Visual Studio 2010\Projects\swtPrice Server\swtPrice Server\Database.obj Error 2 error LNK2019: unresolved external symbol _mysql_init@4 referenced in function "public: void __thiscall Database::connect_db(void)" (?connect_db@Database@@QAEXXZ) D:\Media\Documents\Visual Studio 2010\Projects\swtPrice Server\swtPrice Server\Database.obj Error 3 error LNK1120: 2 unresolved externals D:\Media\Documents\Visual Studio 2010\Projects\swtPrice Server\Debug\swtPrice Server.exe 1 </code></pre> <p>Here is a snippet of code that I copied online and trying to compile:</p> <pre><code>MYSQL *connection, mysql; MYSQL_RES *result; MYSQL_ROW row; int query_state; mysql_init(&amp;mysql); //connection = mysql_real_connect(&amp;mysql,"host","user","password","database",0,0,0); connection = mysql_real_connect(&amp;mysql,"localhost","bainm","not_telling","cpp_data",0,0,0); if (connection == NULL) { //cout &lt;&lt; mysql_error(&amp;mysql) &lt;&lt; endl; //return 1; } </code></pre> <p>I configured my project to include the MySQL's include directory. This is how it looks like in the command line under the C/C++ tab:</p> <pre><code>/I"D:\Program Files\MySQL\MySQL Server 5.5\include" /ZI /nologo /W1 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yu"StdAfx.h" /Fp"Debug\swtPrice Server.pch" /Fa"Debug\" /Fo"Debug\" /Fd"Debug\vc100.pdb" /Gd /analyze- /errorReport:queue </code></pre> <p>I configured my to include the MySQL's Library directory. This is how it looks like in the command line under the Linker:</p> <pre><code>/OUT:"D:\Media\Documents\Visual Studio 2010\Projects\swtPrice Server\Debug\swtPrice Server.exe" /NOLOGO /LIBPATH:"D:\Program Files\MySQL\MySQL Server 5.5\lib" "D:\Program Files\MySQL\MySQL Server 5.5\lib\libmysql.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Debug\swtPrice Server.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\Media\Documents\Visual Studio 2010\Projects\swtPrice Server\Debug\swtPrice Server.pdb" /SUBSYSTEM:CONSOLE /PGD:"D:\Media\Documents\Visual Studio 2010\Projects\swtPrice Server\Debug\swtPrice Server.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE </code></pre> <p>This is how the mySQL library directory looks like:</p> <pre><code> Directory of D:\Program Files\MySQL\MySQL Server 5.5\lib 05/06/2011 10:38 AM &lt;DIR&gt; . 05/06/2011 10:38 AM &lt;DIR&gt; .. 05/06/2011 10:38 AM &lt;DIR&gt; debug 03/31/2011 04:53 PM 4,177,408 libmysql.dll 03/31/2011 04:53 PM 23,920 libmysql.lib 03/31/2011 04:52 PM 10,625,266 mysqlclient.lib 05/06/2011 10:38 AM &lt;DIR&gt; plugin </code></pre> <p>Any help is appreciated. Thank you in advance for any help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload