cannot find -lmysqlclient
I'm trying to compile a C++ program and one of the classes uses . g++ is not able to find the libraries would be my guess. The command i use to compile is -
g++ c1.cpp c2.cpp c3.cpp c4.cpp -o c4 -lm -lmysqlclient
c3.cpp is the file that needs mysql.h. This works perfectly on my local machine, but refuses to run on the server with the error
cannot find -lmysqlclient
I tried finding the libmysqlclient.so files on the server using the find
command, I don't think they are present there
uname -a
reveals
SunOS opteron 5.10 Generic_139556-08 i86pc i386 i86pc
user@opteron 12:26:02 ~/c++/projname/
I realize tha开发者_C百科t i need to link some libraries, but where and how?
Any help would be appreciated. Thanks.
Whatever library packages u think is not installed can be installed using sudo apt-get install
. But the problem is to find the right name of the package apt-get can understand. So how to do that ?! simple
use command : sudo apt-cache search <filename>
For eg.: in this case lmysqlclient
sudo apt-cache search mysqlclient
(remember to exclude 'l' from the actual name ,ie, mysqlclient and not lmysqlclient). This outputs:
libmysqlclient-dev - MySQL database development files
In the above -libmysqlclient-dev
is the name that apt-get
can recognize and solve our cannot find lmysqlclient
problem
so now type: sudo apt-get install libmysqlclient-dev
from interface.
After its done, try making your required file.
Simplifying @SriHariY.S's answer-
Try installing it with sudo apt-get install libmysqlclient-dev
.
Do you have the MySQL client libraries? Can you look for it as
find / -name "libmysqlclient.so" -type f -print 2>/dev/null
Also, you can use the -R
flag on linker to hardlink the libmysqlclient as
g++ -R/usr/local/mysql/lib ....
Or, you can export the LD_LIBRARY_PATH_32
or LD_LIBRARY_PATH_64
as
export LD_LIBRARY_PATH_32=$MYSQL_HOME/lib
Urko,
On Ubuntu 18 I used this command to find a name of required package for fixing this error:
apt search lmysqlclient
After this I installed missing package:
sudo apt install libmariadbclient-dev-compat
精彩评论