Portable notes for SQLite-3.5.1 on arm-linux platforms

Source: Internet
Author: User
SQLite-3.5.1 transplant notes on the arm-linux platform-Linux general technology-Linux programming and kernel information, the following is read details. (1)decompress sqlite-3.5.1.tar.gz to/root/sqlite-3.5.1 to create a same level directory/root/sqlite-3.5.1/build

# Tar zxvf sqlite-3.5.1.tar.gz
# Mkdir/root/sqlite-3.5.1/build
# Cd/root/sqlite-3.5.1/build

(2) set the cross-compilation environment
# Export PATH =/usr/local/arm/3.4.1/bin: $ PATH

(3) check whether the cross-compiler arm-linux-gcc is correct. You can skip this step.
Which arm-linux-gcc check whether/usr/local/arm/3.4.1/bin/arm-linux-gcc

(4) Configuration:
# ../Configure -- host = arm-linux -- prefix = root/sqlite-3.5.1/build -- disable-tcl

If everything goes well, some related files will be generated in the/root/sqlite-arm-linux Directory: config. log config. status libtool Makefile sqlite3.pc

(5) Compilation and installation:
# Make & make install

Note: "# make install" this step will generate a binary executable file sqlite3 in/root/sqlite-3.5.1/build/bin,/root/sqlite-3.5.1/build/include to generate the header file sqlite3.h, and generate libsqlite3.a static library file and libsqlite3.so in/root/sqlite-3.5.1/build/lib. 0.8.6.

# Make doc

You can generate help documents for future query.

In this way, sqlite3 and related lib files used in arm-linux are generated (sqlite3 is built, and the related libraries are in sqlite-arm-linux/lib ).

(6) strip the debugging information and optimize the library files.
# Cd/root/sqlite-3.5.1/build/lib
# File libsqlite3.so. 0.8.6
Libsqlite3.so. 0.8.6: ELF 32-bit LSB shared object, ARM, version 1 (ARM), not stripped

The generated sqlite library file has not been strip yet. You can run the "file libsqlite3.so. 0.8.6" command to view the file information. After processing with strip, the debugging information will be removed, and the execution file size will be much smaller.

The command is as follows:
# Arm-linux-strip libsqlite3.so. 0.8.6

(7) The file is compiled as follows: arm-linux-gcc? O sqlite_insert.o sqlite_insert.c? I/root/sqlite-arm-linux/include? L/root/sqlite-arm-linux/lib-lsqlite3

(8) If you add the header file sqlite3.h and the library file libsqlite3.a and libsqlite. so to the cross compiler directly, you do not need to specify the header file and library file every time as described above. You can add sqlite3.h to/usr/local/arm/3.4.1/arm-linux/include, the library file can be added to/usr/local/arm/3.4.1/arm-linux/lib.

Compilation instructions

Method 1: static Compilation

Add the-static parameter during compilation, for example
[Root @ localhost temp] # gcc opendbsqlite. c-o db. out-lsqlite3-L/root/sqlite-3.5.1/build/lib-I/root/sqlite-3.5.1/build/include-static

The output file db. out is 1596988 kb.

Run, okay, no error
[Root @ localhost temp] #./db. out
You have opened a sqlite3 database named zieckey. db successfully!
Congratulations! Have fun! ^-^

Method 2: reconfigure the system environment variable LD_LIBRARY_PATH
In this case, you must specify the path of the libsqlite3.so. 0 library file, that is, configure the system environment variable LD_LIBRARY_PATH, so that the system can find libsqlite3.so. 0.

Remove-static. During Compilation:
[Root @ localhost temp] # gcc opendbsqlite. c-o db. out-lsqlite3-L/root/sqlite-3.5.1/build/lib-I/root/sqlite-3.5.1/build/include
[Root @ localhost temp] # ll
Total usage 36
-Rwxr-xr-x 1 root 12716 November 13 10:56 db. out
-Rw-r -- 1 root 614 November 13 10:31 opendbsqlite. c
[Root @ localhost temp] #

The size of the output file db. out is 12716 kb, which is much smaller than the static compilation.

Therefore, we recommend using the dynamic compilation method.

Now let's specify the value of the system environment variable LD_LIBRARY_PATH.

Input in shell:
[Root @ localhost temp] # export LD_LIBRARY_PATH =/root/sqlite-3.5.1/build/lib: $ LD_LIBRARY_PATH

Run again
[Root @ localhost temp] #./db. out
You have opened a sqlite3 database named zieckey. db successfully!
Congratulations! Have fun!

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.