Linux QT uses SQLite for static library Compilation

Source: Internet
Author: User

Sqlite3 compilation and Installation

------------------------ Arm version ----------------------

1.download sqlite-autoconf-3070602.tar.gz from the official website

2. decompress the package and enter the current directory.

3. Start the configuration and execute the following command (the cross-compilation environment must be configured ):
./Configure -- prefix =/usr/local/sqlite_arm -- Host = arm-Linux

4. Start compilation and run the following command:
Make

5. Run the following command to start installation:
Make install

6. After installation, go to/usr/local/sqlite_arm. There is something in it (bin lib include share)
Generation instructions are successfully installed.

7. Copy the entire Installation File sqlite_arm to the Development Board.

8. Go to the bin directory of sqlite_arm and configure the environment as follows:
Export LD_LIBRARY_PATH =/mnt/sqlite3_arm/lib: $ LD_LIBRARY_PATH

9. Run the following command:
./Sqlite3
If it succeeds, the sqlite3 version is displayed, and sqlite3 is successfully transplanted here.
------------------------------------------------------

----------------- Sqlite3 static library -----------------
1. After installing sqlite3 for ARM, go to the lib directory under the installation directory sqlite3_arm. The content is as follows:

Libsqlite3.a libsqlite3.so libsqlite3.so. 0.8.6
Libsqlite3.la libsqlite3.so. 0 pkgconfig

2. Copy libsqlite3.a to your application.ProgramDirectory (for example, My qtcreator application test_sqlite_static)
Copy sqlite3.h to test_sqlite_static under the include directory of sqlite3_arm.

3. Add the following content to the test_sqlite_static.pro configuration sheet of qtcreator:

Libs + =-L/root/test_sqlite_static/
Lsqlite3

4. Add an existing header file sqlite3.h to the project.

5. The main program main. cpp is as follows:
# Include <qtcore/qcoreapplication>
# Include "sqlite3.h"
# Include <stdio. h>
# Include <stdlib. h>
Int main (INT argc, char * argv [])
{
Qcoreapplication A (argc, argv );
Sqlite3 * DB = NULL;
Char * zerrmsg = 0;
Int RC;

Rc = sqlite3_open ("test. DB", & dB );
If (RC)
{
Fprintf (stderr, "can't open database: % s/n", sqlite3_errmsg (db ));
Sqlite3_close (db );
Return 0;
}
Else printf ("You have already successfully! /N ");
Sqlite3_close (db );

// Return a.exe C ();
Exit (1 );
}

6. Set the QT version in the build settings item of projects in qtcreator to the QT/e version.

7. Compile the program and copy the program to the Development Board:
Libqtcore. so.4 libqtnetwork. so.4 libqttest. so.4

8. Run the program./test_sqlite_static. If the program is successful, the test. DB file is generated in the current directory.

 

 Note:

Make errors:

" arm-None-Linux-gnueabi-GCC: 3.7.6.2 ": no such file or directory"
the space in line 3.7.6.2 of makefile 127 is caused, remove the space before '3' and compile it.

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.