3

Currently, I have a project in C++ where i have to get a mysql database and ask for tablevalues. I understand that now I have to import the mysql library.

So I do so by going to this site: MySQL Mac OSX 10.7 (64bit)

Now that I have successfully downloaded the files and imported the include folder and libraries that the folder contains, I get this error in the mysql.driver.h file I imported with the rest of the mysql files in the folder I just recently downloaded ...

#include <boost/scoped_ptr.hpp> // 'boost/scoped_ptr.hpp' file not found

So this is telling me that this templated header file was not found...

Do I need to download the boost library now? I did and imported BOOST into my project but it just gave me more errors...

Anyone ran into this same issue before or can help? :) I'd greatly appreciate it!

EDIT

I also read up on a forum in the mySQL webpage and saw that I would need to add linker flags and header/library search paths? I did this but nothing helped :(

Header Search Paths - /usr/local/mysql/include

Library Search Paths - /usr/local/mysql/lib

Other Linker Flags -lz -lm -lmysqlclient
4
  • What's the path of the boost/scoped_prt.hpp file relative to your header file? Commented Jul 30, 2013 at 21:21
  • Well... I actually just removed the boost library and headers from the project... Will i need to redownload the boost files? Commented Jul 30, 2013 at 21:23
  • /Users/settingj/Documents/Country-State Parse/include/mysql_connection.h this is the path of the file "mysql_connection.h... Is that the question your asking? Commented Jul 30, 2013 at 21:23
  • So I just had a talk with one of the software engineers that I work with and I am informed that... If your going to use the C++ mySQL connector, you're going to have to install boost as well... Pretty lame... Commented Jul 30, 2013 at 22:07

2 Answers 2

1

I am a newbie and had a hard time on getting the C++ connector for mysql to work under Xcode. These are the steps necessary for it to work:

  1. Download the MySQL C connector dmg package and install it. This package installs in /usr/local/mysql-connector.... Rename that folder to mysql. (in order to view the /usr folder in finder click on the GO menu and then on GO TO FOLDER once there type in /usr.)
  2. Download the MySQL C++ connector binary. Uncompress it by double clicking the file. Once the file uncompresses, create a folder named mysqlCPP in /usr/local/ (you will now have a folder named mysql and mysqlCPP). Now copy the folders /include and /lib from the uncompressed C++ connector folder to the mysqlCPP folder you just created.
  3. Download the BOOST library from boost.org. Uncompress the downloaded file and copy the boost directory to /usr/local/. (now you should have /mysql /mysqlCPP /boost directories here. There may be additional system folders DONT DELETE THEM.

Now on XCODE open your project and in Build Settings do the following:

  1. Look for OTHER LINKER FLAGS, double click and add the following: -lz -lm -lmysqlcppconn-static (this builds a static reference and a bigger executable, if you wish to link dynamically you need type -lz -lm -lmysqlcppconn but you MUST COPY THE dynamic library into the EXECUTION directory of the file. Add to all options under OTHER LINKER FLAGS.
  2. Look for HEADER SEARCH PATHS, double click and add the following /usr/local/mysqlCPP/include, /usr/local/mysql/include and /usr/local/ all should be added non-recursive. Don't forget to type in for all inputs Debug, Release, Any Architecture, etc.
  3. Look for LIBRARY SEARCH PATHS, double click and add the following: /usr/local/mysql/lib and /usr/local/mysqlCPP/lib. Don't forget to type in for all inputs Debug, Release, Any Architecture, etc. Now you have both installed Connector-C and Connector-C++.
  4. Look for C++ Standard Library and choose the libstdc++ (GNU C++ standard library)

Now you should be set and ready to compile C++ programs. If you wish to use the C connector instead then you should change the OTHER LINKER FLAGS to: -lm -lz -lmysqlclient. Just try with any of the samples on mysql.com and both connectors should work.

Sign up to request clarification or add additional context in comments.

Comments

0

The documentation clearly states boost is required for building the MySQL connector from source

As of MySQL Connector/C++ 1.1.0, the Boost C++ libraries 1.34.0 or newer must be installed. Boost is required only to build the connector,

Once you have boost installed, just point to its installation location

Once Boost is installed, tell the build system where the Boost files are by defining the BOOST_ROOT:STRING option. This can be done when you invoke CMake. For example:

shell> cmake . -DBOOST_ROOT:STRING=/usr/local/boost_1_40_0

1 Comment

I solved the issue ... it's just a hassle/annoying to know a library that you download is dependant to another library that must exist. I downloaded boost, inserted the directory in /usr/local and everything was good... Thanks for your input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.