Linux 下的 SQLite3 的安裝

來源:互聯網
上載者:User

第一步:下載sqlite源碼包,並解壓

>wget http://www.sqlite.org/sqlite-3.6.16.tar.gz

>tar -zxvf sqlite-3.6.16.tar.gz

第二步:安裝

>./configure -disable-tcl

>make

>make install

第三步:編寫代碼測試

>vim sqlite_rw.c

  1. #include <stdio.h>   
  2. #include <stdlib.h>   
  3. #include <string.h>   
  4. #include <sqlite3.h>   
  5.   
  6. int main(int argc, char **argv)  
  7. {  
  8.         sqlite3 *db=0;  
  9.         int  r= sqlite3_open("test.db",&db);  
  10.   
  11.         if (r)  
  12.         {  
  13.                 printf("can't open test.db\n");  
  14.         }else{  
  15.                 printf("open db ok\n");  
  16.         }  
  17.   
  18.         sqlite3_close(db);  
  19.   
  20.         return 0;  
  21. }  

第四步:編譯

>gcc sqlite_rw.c -o sqlite_rw -lsqlite3

相關文章

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.