SQLite3インストール

最新版の3.5.1をCygwinにインストールすると以下のようなエラーが出る。

/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../
libcygwin.a(libcmain.o):(.text+0xab): undefined reference to `_WinMain@16'
collect2: ld はステータス 1 で終了しました
make: *** [sqlite3] エラー 1

一応調べてみたが、解決策が見つからない。代わりに3.2.7のインストール例が見つかったので、バージョンを落として再度インストール。

$ wget wget http://service-spi.web.cern.ch/service-spi/external/tarFiles/sqlite-3.2.7.tar.gz
$ tar xzf sqlite-3.2.7
$ mkdir bid
$ cd bid
$ ../sqlite-3.2.7/configure --disable-tcl
$ make
$ make install

今度は成功。とりあえず使ってみる。

$ sqlite test.db
bash: sqlite: command not found
$ sqlite3 test.db
SQLite version 3.2.7
Enter ".help" for instructions
sqlite> create table user(
   ...> id integer primary key,                                               
   ...> name text, 
   ...> mail text);
sqlite> insert into user(name, mail) values('hoge', 'hoge@gmail.com');
sqlite> insert into user(name, mail) values('ほげ', 'hoge@gmail.com');
sqlite> select * from user;
1|hoge|hoge@gmail.com
2|ほげ|hoge@gmail.com