Connection to MySQL database (driver not loaded) with QT5.5 in CentOS7 (64-bit)

Source: Internet
Author: User

Connection to MySQL database (driver not loaded) with QT5.5 in CentOS7 (64-bit)

To connect to MySQL using qt, you need to share the driver of libqsqlmysql. so. The path is under the plugin/sqldrivers directory. At first glance, it is available, but it is not.

Use the ldd command to analyze libmysqlclient_r.so.16 => not found. Later, it is obvious that libmysqlclient_r.so.16 lacks another shared library. They are dependent and solve this problem to connect qt to the mysql database. The version of the shared library under my/usr/lib64/is higher than that of libmysqlclient. so.18. I thought of a speculative idea to create a symbolic link using ln. However, this is useless.

I can't help but laugh at the fact that QT5.5 was downloaded from the official website. It depends on a lower version. You can't help but be lazy during compilation. It is estimated that they copied libqsqlmysql directly from a lower version. so, no way? Apparently not. Open the qt official website to download the source code and compile it by yourself. Download process skipped, very good to find the http://download.qt.io/official_releases/qt/5.4/5.4.2/submodules/ (no source code qt5.5), find the qtbase about 60 M. The path of the MySql driver is qtbase/src/plugins/sqldrivers/mysql /.
• Qmake
• Make

However, the dynamic library cannot be found in the make process:

/Usr/bin/ld: cannot find-lz
/Usr/bin/ld: cannot find-lssl
/Usr/bin/ld: cannot find-lcrypto

The first one is that zlib-devel is not installed, and yum install zlib-devel is used directly.

The third item cannot be found. Solution:/usr/lib64/create a symbolic link.

Ln-s libssl. so.1.0.1e libssl. so

Ln-s libcrypto. so.1.0.1e libcrypto. so

Make again. Of course, this is not complete yet. Use the new libqsqlmysql. so to replace the old one. This is all done.

View again:

[Sqldrivers] ldd libqsqlmysql. so
Linux-vdso.so.1 => (0x00007fff2d5fe000)
Libmysqlclient. so.18 =>/usr/lib64/mysql/libmysqlclient. so.18 (0x00007feb4ea24000)
Libz. so.1 =>/lib64/libz. so.1 (0x00007feb4e80d000)
Libcrypt. so.1 =>/lib64/libcrypt. so.1 (0x00007feb4e5d6000)
Libnsl. so.1 =>/lib64/libnsl. so.1 (0x00007feb4e3bd000)
Libssl. so.10 =>/lib64/libssl. so.10 (0x00007feb4e150000)
Libcrypto. so.10 =>/lib64/libcrypto. so.10 (0x00007feb4dd6b000)
LibQt5Sql. so.5 =>/home/eric/Qt5.5.0/5.5/gcc_64/lib/libQt5Sql. so.5 (0x00007feb4db2b000)
LibQt5Core. so.5 =>/home/eric/Qt5.5.0/5.5/gcc_64/lib/libQt5Core. so.5 (0x00007feb4d3e3000)
Libpthread. so.0 =>/lib64/libpthread. so.0 (0x00007feb4d1c7000)
Libstdc ++. so.6 =>/lib64/libstdc ++. so.6 (0x00007feb4cec0000)
Libm. so.6 =>/lib64/libm. so.6 (0x00007feb4cbbd000)
Libgcc_s.so.1 =>/lib64/libgcc_s.so.1 (0x00007feb4c9a7000)
Libc. so.6 =>/lib64/libc. so.6 (0x00007feb4c5e6000)
Libdl. so.2 =>/lib64/libdl. so.2 (0x00007feb4c3e1000)
Libfreebl3.so =>/lib64/libfreebl3.so (0x00007feb4c164000)
Libgssapi_krb5.so.2 =>/lib64/libgssapi_krb5.so.2 (0x00007feb4bf1a000)
Libkrb5.so. 3 =>/lib64/libkrb5.so. 3 (0x00007feb4bc39000)
Libcom_err.so.2 =>/lib64/libcom_err.so.2 (0x00007feb4ba35000)
Libk5crypto. so.3 =>/lib64/libk5crypto. so.3 (0x00007feb4b800000)
Libicui18n. so.54 =>/home/eric/Qt5.5.0/5.5/gcc_64/lib/libicui18n. so.54 (0x00007feb4b391000)
Libicuuc. so.54 =>/home/eric/Qt5.5.0/5.5/gcc_64/lib/libicuuc. so.54 (0x00007feb4afe3000)
Libicudata. so.54 =>/home/eric/Qt5.5.0/5.5/gcc_64/lib/libicudata. so.54 (0x00007feb495b9000)
Libgthread-2.0.so.0 =>/lib64/libgthread-2.0.so.0 (0x00007feb493b6000)
Librt. so.1 =>/lib64/librt. so.1 (0x00007feb491ae000)
Libglib-2.0.so.0 =>/lib64/libglib-2.0.so.0 (0x00007feb48e85000)
/Lib64/ld-linux-x86-64.so.2 (0x00007feb4f221000)
Libkrb5support. so.0 =>/lib64/libkrb5support. so.0 (0x00007feb48c76000)
Libkeyutils. so.1 =>/lib64/libkeyutils. so.1 (0x00007feb48a72000)
Libresolv. so.2 =>/lib64/libresolv. so.2 (0x00007feb48858000)
Libselinux. so.1 =>/lib64/libselinux. so.1 (0x00007feb48632000)
Libpcre. so.1 =>/lib64/libpcre. so.1 (0x00007feb483d1000)
Liblzma. so.5 =>/lib64/liblzma. so.5 (0x00007feb481ab000)

Install and configure Gtk and QT compiling environments in Ubuntu

Build a QT environment in Linux

Solution for failure to run the QT console program in Ubuntu and how to configure XTerm

How to port QT4.7.4 in Ubuntu 10.04

Install and deploy the Qt5 development environment in Ubuntu 14.04

Qt details: click here
Qt: click here

This article permanently updates the link address:

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.