Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to fix unresolved external symbol due to MySql Connector C++?
    primarykey
    data
    text
    <p>I followed this tutorial <a href="http://blog.ulf-wendel.de/?p=215#hello" rel="noreferrer">http://blog.ulf-wendel.de/?p=215#hello</a>. I tried both on Visual C++ 2008 and Visual C++ 2010. Either static or dynamic, the compiler gave me the same exact error messages:</p> <pre><code>error LNK2001: unresolved external symbol _get_driver_instance </code></pre> <p>Has anyone experience this issue before? </p> <p>Update:<br> + Additional Dependencies: mysqlcppconn.lib<br> + Additional Include Directories: C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include<br> + Additional Libraries Directories: C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt </p> <p>Another Update: Click F12 on get_driver_instance() linked to:</p> <pre><code>class CPPCONN_PUBLIC_FUNC Driver { protected: virtual ~Driver() {} public: // Attempts to make a database connection to the given URL. virtual Connection * connect(const std::string&amp; hostName, const std::string&amp; userName, const std::string&amp; password) = 0; virtual Connection * connect(std::map&lt; std::string, ConnectPropertyVal &gt; &amp; options) = 0; virtual int getMajorVersion() = 0; virtual int getMinorVersion() = 0; virtual int getPatchVersion() = 0; virtual const std::string &amp; getName() = 0; }; } /* namespace sql */ extern "C" { CPPCONN_PUBLIC_FUNC sql::Driver *get_driver_instance(); } </code></pre> <p>Apparently, the function existed, but the linker could not find it.</p> <p>Code snippet:</p> <pre><code>#include &lt;iostream&gt; #include &lt;sstream&gt; #include &lt;memory&gt; #include &lt;string&gt; #include &lt;stdexcept&gt; using namespace std; #include "mysql_connection.h" #include "mysql_driver.h" #include &lt;cppconn/driver.h&gt; #include &lt;cppconn/exception.h&gt; #include &lt;cppconn/resultset.h&gt; #include &lt;cppconn/statement.h&gt; int main() { try { sql::Driver *driver; sql::Connection *conn; sql::Statement *stmt; sql::ResultSet *res; driver = get_driver_instance(); conn = driver-&gt;connect( "http://localhost/chandb", "root", "chan" ); stmt = conn-&gt;createStatement(); res = stmt-&gt;executeQuery( "select * from another" ); while( res-&gt;next() ) { cout &lt;&lt; "id = " &lt;&lt; res-&gt;getInt( "Id" ); cout &lt;&lt; "id = " &lt;&lt; res-&gt;getInt( "GoldValue" ); cout &lt;&lt; "id = " &lt;&lt; res-&gt;getString( "Model" ); } delete conn; delete stmt; delete res; std::cout &lt;&lt; "This is it"; } catch( sql::SQLException e ) { cout &lt;&lt; e.what(); } } </code></pre> <p>Thanks,<br> Chan</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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