본문 바로가기

Linux

sqlite3 mips compile

[출쳐] : http://www.cnx-software.com/2011/03/14/cross-compilating-sqlite-for-arm-and-mips/


slqite3를 mips로 컴파일해서 사용하기.


1. 우선 sqlite3 소스코드를 다운 받는다.(2012/12/07 현재 ver.3071401)

 wget http://www.sqlite.org/sqlite-autoconf-3071401.tar.gz


2. 압축 해제

  tar xvzf sqlite-autoconf-3071401.tar.gz


3. cross compile 경로 설정

  export PATH=/opt/toolchains/stbgcc-4.5.3-1.3/bin:$PATH


4. sqlite3 폴더로 이동후 다음과 같이 컴파일 환경을 설정한다.

   ./configure --host=mipsel-linux --target=mipsel-linux --prefix=/home/erato/build/sqlite-mips


5. make 

  $> make

  $> make install


6. /home/erato/build에 sqlite-mips 생성됨.



================ 아래는 출처한 곳의 원문이다 ==================

밑에서 말하기를 sqlite3의 최종 라이브러리 크기를 줄일수도 있다고 한다. 

R-tree라는 걸 사용하지 않으려면... 헌데 이렇게까지 크기를 줄일 필요는 없을듯 하다.

그냥 사용하자.


Following my blog entry about Databases for Linux Embedded Systems, here are the instructions to cross-compile SQlite.

First download the latest version of SQLite amalgamation with autoconf script (version 3.75):

wget http://www.sqlite.org/sqlite-autoconf-3070500.tar.gz

Extract the source code:

tar xzvf sqlite-autoconf-3070500.tar.gz

Configure and build the source code. I’ll use mipsel-linux-gcc, but any other cross-compiler could be used.

cd sqlite-autoconf-3070500

./configure --host=mipsel-linux --target=mipsel-linux --prefix=/home/jaufranc/edev/sqlite-mips

make

make install

At this point the library is correctly configured and installed, so you’d just need to copy the relevant files to your target board (skip include and share directories and  libsqlite3.a) .

Let’s check the size of the required files:

ls -l ../sqlite-mips/bin/

-rwxr-xr-x 1 jaufranc jaufranc 125513 2011-03-14 14:21 sqlite

ls -l ../sqlite-mips/lib/libsqlite3.so.0.8.6

-rwxr-xr-x 1 jaufranc jaufranc 2087584 2011-03-14 14:21 ../sqlite-mips/lib/libsqlite3.so.0.8.6

sqlite binary is 122.57KB and the dynamic library 2038.65KB.

Let’s see if we can optimize the binary size with compilation flags and by disabling some unnecessary features.

The first thing to add is CFLAGS=”-Os” to your compilation flags as it will decrease the size by half.

Then if you don’t need it, you could disable R-Tree support (Remove -DSQLITE_ENABLE_RTREE in Makefile.in) and Full Text Search (Remove -DSQLITE_ENABLE_FTS3  in Makefile.in) which will save about 100KB extra.

Instead of using make install, type make install-strip to save more space as it would call mipsel-linux-strip.

Configure, build and install SQLite again:

./configure --host=mipsel-linux --target=mipsel-linux --prefix=/home/jaufranc/edev/sqlite-mips CFLAGS="-Os"

make

make install-strip

sqlite size is now 54.08KB and libsqlite3.so.0.8.6 595.34KB.



Read more: http://www.cnx-software.com/2011/03/14/cross-compilating-sqlite-for-arm-and-mips/#ixzz2EK3JOoT6



===============================================================================

보기 쉽게 정리한 싸이트 : http://m.dbguide.net/about.db?cmd=view&boardConfigUid=19&boardUid=150489#