Port mysql-connector to mini2440

Source: Internet
Author: User
Tags mathematical functions

Since SQLite in the latest development version needs to access MySQL on the server, it is transplanted to MySQL-connector-C to access the server. You can also cross-compile the MySQL source code, however, it seems that MySQL does not support cross-compilation. It is complicated to check the online steps.

1. Download mysql-connector-c-6.0.2.tar.gz

Http://dev.mysql.com/downloads/connector/c/

2. decompress the package to the directory.

3. Install cmake: sudo apt-Get install cmake in Ubuntu

4. I will not elaborate on installing the Cross Compiler (for details, see arm-Linux-gcc-V)

5. Set the Compiler

Export cc = arm-Linux-GCC cxx = arm-Linux-G ++

Added in cmakelists.txt

Set (cmake_cxx_compiler "arm-Linux-G ++ ")
Set (cmake_c_compiler "arm-Linux-GCC ")

6. Generate makefile with cmke

Mkdir mypath

Cmake-G "UNIX makefiles"-dcmake_install_prefix = mypath (mypath is the installation path after cross-compilation)

7. Start Compilation

Make

During the make process, the undefined mathematical functions such as floor (), log (), and pow () may be reported during compilation to 95%, because the-LM parameter must be added during GCC compilation to connect to math. h

Solution:

Vim cmakelists.txt // Add the-LM parameter in the following two parts:

Set (cmake_c_flags "$ {cmake_c_flags}-wall
-Lm ")
Set (cmake_cxx_flags "$ {cmake_cxx_flags}-wall-lm-fno-rtti-fno-exceptions ")

If the RINT () function in include/my_global.h reports an error at the start of compilation, You can annotate all the function bodies and compile them through

Make install

8. Use the compiled library as the QT compilation driver. Because the efficiency of accessing the database through the driver is relatively low, we use the static compilation method to compile the driver into the QT library.

./Configure-Prefix/usr/local/trolltech/qtembedded-arm-opensource-confirm-license-release-shared-Embedded ARM-xplatformqws/Linux-arm-G ++
-Depths 16,18, 24-fast-optimized-qmake-PCH-QT-SQL-SQLite-QT-libjpeg-QT-zlib-QT-libpng-QT-FreeType-little-Endian-host-little- endian-no-qt3support-no-LibTIFF-no-libmng-no-OpenGL-no-MMX-no-SSE-no-sse2-no-3dnow-no-WebKit-no-qvfb-no-phonon- no-NIS
-No-OpenGL-no-cups-no-glib-no-xcursor-no-xfixes-no-xrandroid-no-xrender-no-separate-debug-Info-nomakeexamples-nomake tools-nomake docs-QT-mouse-tslib
-QT-SQL-mysql-I/usr/local/tslib/include-L/usr/local/tslib/lib
-I/usr/local/arm_mysql/include-L/usr/local/arm_mysql/lib

The red part shows the compilation conditions added to the QT library for MySQL driver compilation and the MySQL header file and library dependencies (the MySQL directory has been compiled and installed before)

Since MySQL drivers are compiled into the QT library, the process of porting to the Development Board is the same as that of porting QT, and libmysql In the MySQL lib directory that has been cross-compiled. copy so.16 to the open/lib file. Otherwise, the shared library cannot be found.

Note: At the beginning, I have always reported errors during compilation on ubuntu12.04, but I haven't changed the modified libraries for a long time. I thought that I ran to fedora to compile QT on fedora14 without any errors, it was a good trip, and it was compiled more than an hour later (the VM may be slow)

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.