jbd36
jbd36

Reputation: 493

Using MySQL Connector/C++ in Xcode: -libmysqlcppconn library not found

I'm trying to use MySQL Connector/C++ within Xcode. I have installed MySQL server. I also installed MySQL Connector/C++ and Boost using brew. I believe all files are where they should be.

I've included library search paths:

1) /usr/local/mysql-5.6.24-osx10.8-x86_64/lib

2) /usr/local/mysql/lib

I am just trying to get simple code to run before I dive a little deeper:

#include <stdlib.h>
#include <iostream>

#include "mysql_connection.h"
#include "mysql_driver.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>

using namespace std;

int main(int argc, const char * argv[]) {

    sql::mysql::MySQL_Driver *driver;
    sql::Connection *con;

    driver = sql::mysql::get_mysql_driver_instance();

    con = driver->connect("tcp://127.0.0.1:3306", "user", "password");

    delete con;

    return 0;
}

The error I'm getting is: ld: library not found for -libmysqlcppconn

Any help would be greatly appreciated!

Upvotes: 2

Views: 1827

Answers (1)

Og Mojica
Og Mojica

Reputation: 11

If you are using the Static MySQL Connector/C++ Library, did you link both library files: libmysqlcppconn-static.a and libmysqlclient.a? Do that in Xcode in the "Build Phases" tab under "Link Binary With Libraries" section. After you add those files make sure that the library search paths you provided point to the file locations. For Dynamic Library instead you link the libmysqlcppconn.so file.

Upvotes: 1

Related Questions