Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9205503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:57:53+00:00 2026-06-17T23:57:53+00:00

Using C++ in Xcode I try to access a MySQL database with the MySQL

  • 0

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

EXC_BAD_ACCESS (code=13, address=0x0)

when calling

driver->connect(url, user, pass)

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.

Next thing is, when I compile the program manually using

c++ -o test -I /usr/local/mysqlConnector/include/ -lmysqlcppconn main.cpp

the program runs fine and also runs the INSERT statement on the table.

The program code is taken from the MySQL Connector/C++ examples, namely the pthreads.cpp example, but truncated to the essential parts:

/* Standard C++ includes */
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <stdexcept>

#include <mysql_connection.h>
#include <mysql_driver.h>

#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>

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< sql::Connection > 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->connect(url, user, pass));
        con->setSchema(database);

    sql::Statement* stmt = con->createStatement();
    stmt->execute("INSERT INTO testtable (testnumber) values (5)");
    } catch (sql::SQLException &e) {
        return EXIT_FAILURE;
    } catch (std::runtime_error &e) {
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:57:55+00:00Added an answer on June 17, 2026 at 11:57 pm

    Ok, the problem is solved.

    Here the problem was one compile flag. The MySQL Connector/C++ was compiled without the
    -stdlib=libc++ flag, but Xcode added that compile/link flag to its commands. This caused the crash. This also explains, why the manually compiled program worked, as I didn’t include that flag to the compile command.

    To make it more clear: I recompiled the MySQL Connector/C++ with the -stdlib=libc++ flag. Then the program compiled by Xcode works fine for me. To compile the MySQL Connector/C++ I added

    -DMYSQL_CXXFLAGS=-stdlib=libc++
    

    to the cmake command that needs to be run when installing the connector.

    make VERBOSE=1
    

    then proved that the flag is actually used when compiling the connectors source.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been using Xcode for a while now. One thing that always bugs me
I'm using Xcode 4.5 and I have the following code in my program: char
I am using git in my projects, whenever I try to pull from Xcode
so when i'm running my app using XCode and I can see that my
[Previous description deleted] Let's try again. I am using Xcode's Visual Storyboard. I'm using
I am trying to configure Git repository using Xcode 4. When I try to
Using XCode 4.1 I've come across a crash whenever I try to use a
Experts! Few days ago i was using previous version of xcode. That time my
I'm using Xcode 4.3.1 In my app I try to use Facebook SSO.My requirement
Using XCode 4.4 and Mountain Lion, I have a UIImageView, and on that view,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.