Hi All,

I'm trying to connect to a mysql database using the MySQL Connector from Oracle. I'm hitting my first issue of linking the libraries and was hoping that someone could nudge me in the right direction.

What I have done so far:

Downloaded mysql-connector-c-6.1.3-osx10.7-x86_64.dmg from http://dev.mysql.com/downloads/connector/c/

In XCode, in "Build Settings" for my project, changed;
Header Search Paths to: /usr/local/mysqlConnector/include
and changed;
Library Search Paths > Debug to: /usr/local/mysqlConnector/lib
which changed the part above (next to the "Library Search Paths" text to "<Multiple Values>" (greyed out)

Also, in the "Build Settings" I changed;

Linking > Other Link Flags to: -lmysqlclient -lm -lz

I've added to my main:

MYSQL *connection, mysql;
    mysql_init(&mysql);
    connection = mysql_real_connect(/*stuff/*);

    if (connection == NULL) {
        printf("No connection");
    } else {
        printf("Connected!");
    }

    return 0;

and I'm getting errors on attempting to build:

ld: warning: ignoring file /usr/local/mysqlConnector/lib/libmysqlclient.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/mysqlConnector/lib/libmysqlclient.dylib
Undefined symbols for architecture i386:
  "_mysql_init", referenced from:
      _main in main.o
  "_mysql_real_connect", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any help with this would be much appreciated.

Many Thanks

May be you are working on a 32-bit system.Check it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.