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
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:
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.)
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.
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:
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.
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.
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++.
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.
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
Related
I'm learning to use OpenCV (and C++) in Codeblocks. What confuses me, however, is that when I start to include header files from OpenCV in my main.cpp file, Codeblocks automatically suggests to me the files as shown in the image below.
I have not included any search paths to project build options, so how is this possible that Codeblocks can find the files? Is there some other variable working here that I'm unaware of?
Note that I'm a beginner with both Codeblocks and OpenCV and that I only have a little experience with C++.
Thank you
Of course when you install an IDE like code::blocks by default, it knows about standard path for library on your OS.
On my OS -> Ubuntu that is /usr/include
It only searches on a standard path, except you add one. If you install your library by command-line, it goes to the standard place, if you installed manually, then it depends on your option you added to installation. I can not see you screen-shot but it has access to /usr/include by default.
For more detail on Linux and OpenCV
And here is a screen-shot of codeblock on Ubuntu that I added some 3rd-party library
NOTE:
if you install any libraries by command-line, just use it.
But if you have installed them manually, you need to add 2 things to codeblock.
1. First is your path for header file
2. Second is your path for linker
And you see it in screen-shot that say: Search Directory
First is for header and second is for linker
I'm a mac user and am trying to install and import C++ Armadillo library. Here are the steps I've had so far:
1) I downloaded the Armadillo library from its website.
2) I went over the Readme.txt file in the download file explaining how to install it.
3) I used CMake to make the armadillo download files into binary files.
4) Then by using terminal and the code sudo make install, I installed the binary codes and they generated some "library-like" files: libarmadillo.4.0.2.dylib, libarmadillo.4.dylib, lib armadillo.dylib
5) I then copied all these files into /url/lib directory.
6) Now I have my Xcode program running and I'm trying to include the armadillo library via the include command. The problem is Xcode highlights this line and it says "armadillo file not found". Could anyone please help me solve this issue?
Thanks very much,
You need to set the following things in your build settings:
Header Search Paths: /path/to/armadillo/include (e.g. something like /url/lib/armadillo/include)
This is all you need for your source to compile. However, in order to get your program to link, you will also need the following:
Library Search Paths: /path/to/armadillo/libraries (e.g. something like /url/lib/armadillo/lib)
Other Linker Flags: -larmadillo (or: add the armadillo library to your Link build phase using the GUI)
If you're not exactly sure how to properly build and install armadillo (e.g. which prefix to use when configuring), I highly recommend using a package manager such as MacPorts to do it for you,
Install port from here
run the following command:
sudo port install armadillo
Your header path and library path will be: /opt/local/include and /opt/local/lib respectively
I am reading the follow article Developing MySQL Applications with Eclipse CDT. My Eclipse version is Indigo and my Ubuntu version is 12.04. When I trying build I get the following errors:
/usr/bin/ld: cannot find -lz.a
/usr/bin/ld: cannot find -lmysqlclient.a
I like please get help. I searched mysqlclient.a and z.a libraries but not found these. But I found libmysqlclient.a and libz.a in directory /usr/lib/x86_64-linux-gnu then I add this Library search path but get the error.
How I will be able to fix this?
You passed z.a and mysqlclient.a as libraries. You need to ditch the .a suffix in your project's build settings: it's not part of the library's name. It should be -lz and -lmysqlclient.
Also, adding the library search path (-L) is probably not necessary. /usr/lib and /usr/lib/$arch$ are usually in the default search paths.
You need to install the MySQL client library and the libz compression library. Do an 'apt-cache search' for either.
This question is probably better suited for serverfault.com.
I have seen posts on this before, but none of the answers seemed to work for me. I just installed OpenCV on my Mac and got it to work fine with g++ from the command line. I installed it using Mac Ports:
$ sudo port install opencv configure.compiler=llvm-gcc-4.2
To compile with g++, I use the command:
g++ myfile.cpp -o myprogram -I/opt/local/include -L/opt/local/lib -lopencv_core.2.4.2 -lopencv_calib3d.2.4.2
And my OpenCV include header in the main.cpp file is:
#include "opencv2/opencv.hpp"
And all works well.
Now, when I tried to include the library in Xcode, it simply says 'opencv2/opencv.hpp' file not found. To include the library in Xcode, I followed some detailed instructions. First, to the project target, I added /opt/local/lib to the library search paths, and /opt/local/include, /opt/local/include/opencv and /opt/local/include/opencv2 to the header search paths under the Build Settings tab. Then I clicked on Build Phases, and to Link Binary With Libraries I added all of the OpenCV .dylib files in /opt/local/lib (all 11 of them). This didn't work. I've tried many other things, including adding to user search paths and setting up "Other Linker Flags" for the target. Nothing worked. It can't find the file. If I use the exact path (#include "/opt/local/include/opencv2/opencv.hpp") it can't find all the other header files.
The version of OpenCV is 2.4.2. I am using Xcode 4.3.3 on OS X Lion 10.7.4. This is a C++ project. Any ideas?
This problem can be solved by going to the project properties and click on the target.
In the build settings search "header search path".
And there you add "/opt/local/include".
By doing this you're telling Xcode to look for the header files in that directory also.
Now you can use:
#include <opencv2/opencv.hpp>
If you don't want to do this every time you start a new project you can add the .h and .hpp files to the defaulti include directory Xcode uses. You can find this directory in Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include .
You will have to add the binaries to your project as well. For that you go to "build phases" and then add the binaries in the "Link binaries with libraries" section.
I hope this helps you out.
I'm wondering how to "package" a C++ project for release. It uses various libraries, and I don't want a user to have to go through the same setup I did, with putting the right files in the right place and such. I had difficulty researching this, because I'm not sure the technical term for this issue. If I'm using command line compiling on Linux, is there an easy way to do this?
Your approach to this will differ on Windows and Linux because each OS handles this a different way. I'm more familiar with Linux so I'll restrict my answer to just the Linux side of things.
When you link your executable with a library using -l flag the linker defaults to looking in the normal system library directories so there are four approaches here.
Require the user to properly install the libraries themselves. However, it sounds like you don't want to do that.
Have the user add the library location to LD_LIBRARY_PATH variable.
Your third option is force the linker to look in a certain path for the libraries using the -rpath flag. For example, to have the application look in its working directory for a shared library you can compile with: g++ -rpath ./ -l SomeLib -o MyApp myapp.cpp
One other option is to static link your code with their library that way you only have to distribute one executable. If a static library exists you can use g++ -static -l SomeLib -o MyApp myapp.cpp to tell gcc to link statically.
On windows I would recommand wix http://wix.sourceforge.net/ to create the .msi installer
I would like to point out, the lookup path for .dlls I recommand putting all .dll in the same folder as your .exe since this has the highest priority
However, the vc crt (the c/c++ runtime library) should be installed using the redistributional package from microsoft -> updates automatically http://www.microsoft.com/de-de/download/details.aspx?id=5555
Wix can include the redistributional package into the same .msi therefore you have only to deploy a single installer file.
You mean an installer?
On Windows the program that you run to install a new app which outs everything in the correct directory, creates the start menu and lets you un-install it?
There is an installer builder in Visual Studio (might not be in the free express version) which makes .msi installer files. It's fairly easy to use for simple tasks but becomes complicated to do anything more.
Alternatively, to create traditional setup.exe type installs I use the excellent free Innosetup
On linux you would generally create a package using whatever format your distribution uses (.deb / .rpm ). There are lots of instructions on the specifics of each one and the tools to do so will probably already be installed in your Linux system