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.
Related
There are similar topics, but I haven't managed to find my answer in them.
I am building a test console application using the code::blocks IDE. It needs to load a DVB shared library called libhdhomerun.so (from Silicon Dust) for the HD Homerun DVB tuners. The HDHR tuner library has being installed using ./configure, ..., sudo make install, ldconfig etc and it all works with their utilities (built at the same time). So - the library is there and OK.
The library installed itself into /usr/local/lib. There is actually no symlink to it as there is with other shared libraries, but then it doesn't have any version information on the end either.
When I build the code (having explicitly included /usr/local/lib/libhdhomerun.so), the ld stage fails with
"cannot find -lhdhomerun.so"
I have tried every combination of including (/usr/local/lib/) libhdhomerun.so, hdhomerun.so, libhdhomerun, hdhomerun, creating a symlink to it etc. Nothing makes any difference.
The bizarre thing is that I have udev, mysql and libdvbv5 shared libraries included in exactly the same way, and they are fine. The only one that will not link is hdhomerun.
If I run a manual verbose link step from the command line "ld -lhdhomerun.so --verbose", it does fail - because it is trying to find libhdhomerun.so.so.
Any suggestions gratefully received - but I do need to keep using code::blocks.
To link the library properly, you need to have library path defined in your environment, and use proper library name with -l flag. Library path is defined in LD_LIBRARY_PATH environment variable. For -l flag to g++, library extension should not be provided - as you already observed, so in your case it should be like this:
-lhdhomerun
I want to build an autotools project which is making use of the boost libraries program_options and iostreams. Therefor I install those libraries:
sudo aptitude install libboost-iostreams-dev libboost-program_options-dev
Now ./configure is fine and the progam compiles. However the linking fails:
/usr/bin/ld: cannot find -lboost_program_options-mt
/usr/bin/ld: cannot find -lboost_iostreams-mt
This is a well documented issue and can be fixed either by fixing the autotools stuff or by linking boost_program_options to boost_program_options-mt and so forth. I choose to do the latter since this is not my project. However I am failing to locate the libraries installed in Ubuntu:
locate *boost*
returns a list of documentation and package information and some boost libraries I am not looking for. locate *program_options* is empty. The library is not under /usr/lib or /lib ... Any ideas?
For me they are under /usr/lib64 in ubuntu 13.04. But I would use boost m4
to let autotool take care of these dependencies automatically. So by including boost m4 in your configure.in, you can specify which boost modules and versions you require. Morever it would also find the required paths for you.
sometimes its impossible, especially for smaller apps and custom projects,
for future, boost includes are in /usr/include/boost ,
of course it depends on system type and distribution
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
I'm getting the following error:
ld.exe||cannot find -lD:\Libraries\boost_1_47_0\boost_1_47_0\stage\lib|
Even though the path is valid. Any thoughts on that?
Edit:
Thanks MichalR!
For others, in order to configure boost for gcc:
Download boost
install it according to instructions from boost site
In code::blocks in Settings/global variables add path to your boost library for base and lib fields (this should be located in stage/lib folder)
In code::blocks in Project/Build options..., linker settings tab, link libraries - add here those libraries
In code::blocks in Project/Build options...Search directories tab in compiler subtab add $(#boost) and in linker subtab add $(#boost.lib).
Done. I spent a few days on this, but it was worth it. Now I can use this great IDE with gcc compiler which at the moment of this writing is miles ahead of MS. I am not being stopped in my personal development by MS - C++11 here I come!
The params for ld are e.g.:
-larchive
-Lsearch_path
The first tells what library to look for, the latter specifies library search paths.
Perhaps you have these options mixed in your command line - it looks you have -l with a directory parameter.
I have gcc 4.4.5 and the latest boost library. I want to use boost specifically for its regex library. I tried using the built in c++ regex functions but apparently they are not fully functional yet. I followed a tutorial online to set up netbeans.
I added /usr/include/boost to the c++ code assistance include directories. I then added -lboost_regex-mt to the build>linker>additional options area in the project configuration. but I still get this error:
/usr/bin/ld: cannot find -lboost_regex-mt
collect2: ld returned 1 exit status
This is the command thats being created by netbeans:
g++ -lboost_regex-mt -o dist/Debug/GNU-Linux-x86/examples01 build/Debug/GNU-Linux-x86/main.o
I also tried doing it with -lboost-regex and -lboost-regex-st and the same error, with only the mt changed.
I also tried running a file using regex objects through the terminal but still got the same error. Can anyone help with this problem? Or at least point me in the right direction?
You have to set your project's "Additional Library Directories" so that it knows what other directories to look into for your libraries to link against.
Here's a screenshot from Netbeans' site here: http://netbeans.org/community/magazine/html/03/c++/
edit: note that this will affect the generated compiler command to have -L options which specify additional locations to look for library files.
You need to tell g++ where to find the libraries. One way doing this is to append the location of boost's libraries to your LD_LIBRARY_PATH. Note that this is not the same as the header files (the .hpp files in the include directory) which you said you've already included in your project.