An error occurred while connecting to MySQL in Linux C.

Source: Internet
Author: User

The following error occurs when connecting to MySQL in Linux C:

After the compilation is successful, run the program./connect: error while loading shared libraries: libmysqlclient. so.15: cannot open shared object file: No such file or directory.

The above error occurs because the libmysqlclient. so.15 library file is not found during system running. There are two solutions:

Method 1: directly copy the libmysqlclient. so.15 file to the/usr/lib library directory specified by the system.

Method 2: Set the/etc/ld. so. conf file, edit the file, add the directory libmysqlclient. so.15 to the file, save and exit. Note that after each change to ld. so. conf, you need to run ldconfig to confirm the refresh.

Method 3: Add/usr/local/mysql/lib/mysql to you LD_LIBRARY_PATH environment variable

Ldconfig usage: ldconfig [options] [libs]

The command ldconfig determines the links required to run the shared libraries in the/usr/lib directory and/lib directory. These links are specified in the libs on the command line and saved in/etc/ld. so. conf. The command ldconfig and dynamic link/loading tool ld. so work together to create and maintain links to the latest shared library.

Two options of ldconfig

-P: only the content of the/etc/ld. so. cache file is printed. This file is the current list of shared libraries known to ld. so.
-V: update/etc/ld. so. cache, list the version numbers of each database, scan directories, and all created and updated links.

Additional information:

When installing mysql, specify the parameter when running "./configure" (only part of this article is described. For other parameters, enter "./configure -- help" to query)

./Configure -- prefix =/usr -- sysconfdir =/etc
Installation directories:
-- Prefix = PREFIX install architecture-independent files in PREFIX
[/Usr/local]
-- Exec-prefix = EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, 'Make install' will install all the files in
'/Usr/local/bin','/usr/local/lib' etc. You can specify
An installation prefix other than '/usr/local 'using' -- prefix ',
For instance '-- prefix = $ home '.
Fine tuning of the installation directories:
-- Bindir = DIR user executables [EPREFIX/bin]
-- Sbindir = DIR system admin executables [EPREFIX/sbin]
-- Libexecdir = DIR program executables [EPREFIX/libexec]
-- Datadir = DIR read-only architecture-independent data [PREFIX/share]
-- Sysconfdir = DIR read-only single-machine data [PREFIX/etc]
-- Sharedstatedir = DIR modifiable architecture-independent data [PREFIX/com]
-- Localstatedir = DIR modifiable single-machine data [PREFIX/var]
-- Libdir = DIR object code libraries [EPREFIX/lib]
-- Includedir = dir c header files [PREFIX/include]
-- Oldincludedir = dir c header files for non-gcc [/usr/include]
-- Infodir = DIR info documentation [PREFIX/info]
-- Mandir = DIR man documentation [PREFIX/man]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.