External Libraries in XCode

February 6, 2008 – 5:44 pm

I need to compile something and use the MySQL C++ library. I have mysql and mysql++ already compiled, I won’t go over how to do that now.

I added the following code to the top of my source:


#include <mysql++.h>

I got an error

/Users/jhaddad/dev/search_engine/main.cpp:4:21: error: mysql++.h: No such file or directory

Not cool.

How to fix:

In XCode, open up the project settings (under the project menu). Click the build tab. Go down to search paths, and you can change your Header search paths to the correct locations where you installed whatever you’re looking for. In this case, mine was /usr/local/includes and /usr/local/mysql/

Next time you try to recompile, you’ll get a different error, this time it should be during Linking. Might look something like the below.

“mysqlpp::Query::store(mysqlpp::SQLQueryParms&)”, referenced from:

Right click on your project in the left hand column (file listing), click “Add existing files”, then go to the prebuilt library (for me it was in /usr/local/lib), and add the file. You don’t have to copy it into the directory, you can just add it and it should work. Recompile and enjoy.

Edit: /usr/local/lib won’t be initially visible. Type command-shift-g and it’ll bring up a text field you can type a path into to go directly to a directory.
xcode_header

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Reddit
  1. 3 Responses to “External Libraries in XCode”

  2. I am trying to use mysql++ on mac (10.5.5) using Xcode. I already have “/usr/local/includes and /usr/local/mysql/” in the header and library search paths. Also i have added :

    “libmysqlclient.a”, “libmysqlpp_excommon.a” by using add existing files. I could NOT find the “mysqlpp.dylib” or the “libmysqlpp.a/so” anywhere. Its these files that the linker is asking for.. but where are they?? I have searched the build folders and the all the possible lib and include folders as well….

    I have been trying for last few days and dont know what the problem is.. and if i have done anything wrong in installing mysql++ .

    can someone help??

    By amit on Oct 2, 2008

  3. Mine were here:
    /usr/local/mysql/lib/mysql/libmysqlclient.15.0.0.dylib
    /usr/local/lib/libmysqlpp.2.3.2.dylib

    Did you build MySQL yourself? I’m not sure if it comes w/ the libraries you’ll need if you don’t build it.

    By jon on Oct 2, 2008

  4. I got the it to work finally… only thing needed to do was to give to correct path… therefore i copied the required files “libmysqlpp.dylib”, “libmysqlpp.3.dylib”, to the /usr/local/lib/ folder..

    thanks a lot

    By amit on Oct 3, 2008

Post a Comment