Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL Connector/C++ BAD ACCESS crash
    text
    copied!<p>Using C++ in Xcode I try to access a MySQL database with the MySQL Connector/C++. Problem is that the program (compiled with Xcode) always crashes with </p> <pre><code>EXC_BAD_ACCESS (code=13, address=0x0) </code></pre> <p>when calling</p> <pre><code>driver-&gt;connect(url, user, pass) </code></pre> <p>In Xcode I created a complete new project (OS X > Command Line Tool), inserted the code (see below) in the main.cpp, added Boost and MySQL Connector header include paths as well as libmysqlcppconn.6.1.1.1.dylib as Link Library and hit the Run button.</p> <p>Next thing is, when I compile the program manually using</p> <pre><code>c++ -o test -I /usr/local/mysqlConnector/include/ -lmysqlcppconn main.cpp </code></pre> <p>the program runs fine and also runs the INSERT statement on the table.</p> <p>The program code is taken from the MySQL Connector/C++ examples, namely the pthreads.cpp example, but truncated to the essential parts:</p> <pre><code>/* Standard C++ includes */ #include &lt;stdlib.h&gt; #include &lt;iostream&gt; #include &lt;sstream&gt; #include &lt;stdexcept&gt; #include &lt;mysql_connection.h&gt; #include &lt;mysql_driver.h&gt; #include &lt;cppconn/driver.h&gt; #include &lt;cppconn/exception.h&gt; #include &lt;cppconn/resultset.h&gt; #include &lt;cppconn/statement.h&gt; std::string url; std::string user; std::string pass; std::string database; /** * Usage example for Driver, Connection, (simple) Statement, ResultSet */ int main(int argc, const char **argv) { sql::Driver *driver; std::auto_ptr&lt; sql::Connection &gt; con; url = "tcp://127.0.0.1:3306"; user = "appserver"; pass = "testpw"; database = "appserver"; try { driver = sql::mysql::get_driver_instance(); /* Using the Driver to create a connection */ con.reset(driver-&gt;connect(url, user, pass)); con-&gt;setSchema(database); sql::Statement* stmt = con-&gt;createStatement(); stmt-&gt;execute("INSERT INTO testtable (testnumber) values (5)"); } catch (sql::SQLException &amp;e) { return EXIT_FAILURE; } catch (std::runtime_error &amp;e) { return EXIT_FAILURE; } return EXIT_SUCCESS; } </code></pre>
 

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