1.vc select Դ?源码?
2.贪吃蛇c语言代码
3.å¦ä½ç¼è¯SQLite-How To Compile SQLite
vc select Դ??
用vb.net做的校友录……(附所有源代码)
来源:不详 作者 佚名 点击数: 录入时间:-- ::
想必大家都上过校友录吧,里面的源码功能虽然不是很强大,但是源码为我们这些毕业之后各奔西东的学子来说,到真是源码提供了一个好的聚集点,下面是源码我用vb.net做的校友录,当然也不能说是源码征途源码 linux校友录了,只能说是源码我们班的学友录了:)不过只要你掌握了这种编程思想,校友录就不在话下了。源码这里我将重点谈一下关于管理员权限赋予。源码
以前有这个想法的源码时候,难就难在管理员身份的源码赋予上,开始想如果一般用户在被提升为管理员之后,源码我可以把他的源码信息转到另外一个表中,以后登陆的源码时候先检查manage表中是否有他就行了,这种办法我已经实现了,源码一线筹码选股指标源码公式是不是有些笨……可是正在我要正式开工的时候,一个想法突然冒了出来,是什么呢?呵呵,就是在数据库中再增加一个字段了如果是第一次注册就让这个字段item(int)的值为0,要是被提升之后就update为1,班级创始人呢?当然了,在他申请时付给他一个班级id,企业内部管理系统源码下载然后先判断班级id为这个已经注册的人信息条数是否为0,如果是,那么就付给他item=2好了。下面的代码中,我没有实现这个功能,因为我做的是班友录的,当然了,通达信龙头股排序指标源码我就是管理员喽:)
在这里,我使用的是checkboxlist(两个),一个用来转换数据(visibe=fause),一个用来显示数据,还有一个checkbox用来写全部选中的事件。当然了还有两个按钮事件,一个是白天鹅加工厂溯源码查询用来提升为管理员的,一个是用来降级为一般用户的,这两个按钮在判断为一般用户时
enable都是为fause的,只有当判断登录为管理员时才为true。当然了,如果你是班级创始人,是不可能被降级的:)
这里用来显示信息的我用的是一个datagrid,当判断为非管理员时,删除栏的visible将为fause,为管理员的时候,才为true,也就是说只有管理员才可以删除信息。而不是注册的用户是不能发言的所有的按钮控件的enable将都为fause。
代码如下:board.aspx
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="boaman.aspx.vb" Inherits="_re1.boaman"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title></title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="javascript" name="vs_defaultClientScript">
<meta content="/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body background="image/bg.gif" MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:checkbox id="yourcheck" style="Z-INDEX: ; LEFT: px; POSITION: absolute; TOP: px" runat="server" Text="全部选中" AutoPostBack="True" ForeColor="SaddleBrown" Font-Bold="True"></asp:checkbox>
<asp:button id="Button1" style="Z-INDEX: ; LEFT: px; POSITION: absolute; TOP: px" runat="server" Text="提升为管理员" Height="px" Width="px" BackColor="Gainsboro" BorderColor="Lavender" BorderWidth="2px" BorderStyle="Outset"></asp:button>
<asp:button id="Button2" style="Z-INDEX: ; LEFT: px; POSITION: absolute; TOP: px" runat="server" Text="降级为一般用户" Height="px" Width="px" BackColor="Gainsboro" BorderColor="Lavender" BorderWidth="2px" BorderStyle="Outset"></asp:button>
<asp:checkboxlist id="CheckBoxList1" style="Z-INDEX: ; LEFT: px; POSITION: absolute; TOP: px" runat="server" Visible="False"></asp:checkboxlist>
<asp:checkboxlist id="mycheck" style="Z-INDEX: ; LEFT: px; POSITION: absolute; TOP: px" runat="server" ForeColor="Navy" Font-Size="X-Small"></asp:checkboxlist>
<asp:label id="Label1" style="Z-INDEX: ; LEFT: px; POSITION: absolute; TOP: px" runat="server" ForeColor="Red" Font-Names="方正姚体">(已注册用户)</asp:label>
<asp:image id="Image1" style="Z-INDEX: ; LEFT: px; POSITION: absolute; TOP: px" runat="server" Height="px" Width="px" ImageUrl="image/re1-1.gif"></asp:image>
<asp:datagrid id="DataGrid1" style="Z-INDEX: ; LEFT: px; POSITION: absolute; TOP: px" runat="server" Height="px" Width="px" BorderColor="#ffcc" AutoGenerateColumns="False" HeaderStyle-Font-Size="9" HeaderStyle-HorizontalAlign="Center" HeaderStyle-ForeColor="red" HeaderStyle-Font-Bold="True">
<Columns>
<asp:HyperLinkColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Height="" ItemStyle-Font-Size="9" DataNavigateUrlField="stu_id" DataNavigateUrlFormatString="querry.aspx?stu_id={ 0}" DataTextField="stu_id" HeaderText="学号"></asp:HyperLinkColumn>
<asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="" ItemStyle-Font-Size="9" DataField="tel" HeaderText="电话"></asp:BoundColumn>
<asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="" ItemStyle-Font-Size="9" DataField="oicq" HeaderText="OICQ"></asp:BoundColumn>
<asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="" ItemStyle-Font-Size="9" DataField="email" HeaderText="E-mail"></asp:BoundColumn>
<asp:BoundColumn ItemStyle-ForeColor="navy" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="" ItemStyle-Font-Size="9" DataField="point" HeaderText="登录次数"></asp:BoundColumn>
</Columns>
</asp:datagrid>
</form>
</body>
</HTML>
下面是codebehind中的内容:boaman.asp.vb
Imports System.Data
Imports System.Data.SqlClient
Public Class boaman
Inherits System.Web.UI.Page
Protected WithEvents yourcheck As System.Web.UI.WebControls.CheckBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents CheckBoxList1 As System.Web.UI.WebControls.CheckBoxList
Protected WithEvents mycheck As System.Web.UI.WebControls.CheckBoxList
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Dim conn As SqlConnection = New SqlConnection("server=lixinri;uid=sa;pwd=;database=re1")
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'////////////////////判断是否为过客
If Session("stu_id") = "" Then
Button1.Enabled = False : Button2.Enabled = False
'////////////////////调用check()事件
check()
Else
If Not IsPostBack Then
Dim sql As String = "select * from pwd where stu_id=@stu_id"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
comm.Parameters.Add(New SqlParameter("@stu_id", SqlDbType.Int, 4))
comm.Parameters("@stu_id").Value = Session("stu_id")
Dim dr As SqlDataReader
conn.Open()
dr = comm.ExecuteReader
While dr.Read
If dr.Item("term") = "0" Then
'///////////////////判断是否为一般用户
dr.Close()
Button1.Enabled = False : Button2.Enabled = False
Dim sql_1 As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"
Dim cmd As New SqlCommand(sql_1, conn)
dr = cmd.ExecuteReader
While dr.Read
If dr.Item("term") = "1" Then
mycheck.Items.Add("<u>" & dr.Item("name") & "</u>" & "<font color=darkorange>(管理员)</font>")
ElseIf dr.Item("term") = "2" Then
mycheck.Items.Add("<u>" & dr.Item("name") & "</u>" & "<font color=red>(班级创始人)<font>")
Else
mycheck.Items.Add("<u>" & dr.Item("name") & "</u>")
End If
CheckBoxList1.Items.Add(dr.Item("stu_id"))
End While
Else
'////////////////////判断是否为管理员
dr.Close()
Button1.Enabled = True : Button2.Enabled = True
Dim sql_1 As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"
Dim cmd As New SqlCommand(sql_1, conn)
dr = cmd.ExecuteReader
While dr.Read
If dr.Item("term") = "1" Then
mycheck.Items.Add("<u>" & dr.Item("name") & "</u>" & "<font color=darkorange>(管理员)</font>")
ElseIf dr.Item("term") = "2" Then
mycheck.Items.Add("<u>" & dr.Item("name") & "</u>" & "<font color=red>(班级创始人)<font>")
Else
mycheck.Items.Add("<u>" & dr.Item("name") & "</u>")
End If
CheckBoxList1.Items.Add(dr.Item("stu_id"))
End While
End If
End While
dr.Close()
'////////////////////////取出数据,填充dataset
Dim mysql As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"
comm = New SqlCommand(mysql, conn)
Dim mycomm As SqlDataAdapter = New SqlDataAdapter(mysql, conn)
Dim ds As DataSet = New DataSet()
mycomm.Fill(ds, "base")
DataGrid1.DataSource = ds.Tables("base").DefaultView
DataGrid1.DataBind()
End If
End If
End Sub
'///////////////////////书写check()事件
Sub check()
If Not IsPostBack Then
Dim mysql As String = "select a.stu_id as stu_id,a.term,b.name as name,b.tel as tel,b.call as oicq,b.point as point,b.email from pwd a,stu_base b where a.stu_id=b.stu_id"
Dim comm As New SqlCommand(mysql, conn)
Dim dr As SqlDataReader
conn.Open()
dr = comm.ExecuteReader
While dr.Read
If dr.Item("term") = "1" Then
mycheck.Items.Add("<u>" & dr.Item("name") & "</u>" & "<font color=darkorange>(管理员)</font>")
ElseIf dr.Item("term") = "2" Then
mycheck.Items.Add("<u>" & dr.Item("name") & "</u>" & "<font color=red>(班级创始人)<font>")
Else
mycheck.Items.Add("<u>" & dr.Item("name") & "</u>")
End If
CheckBoxList1.Items.Add(dr.Item("stu_id"))
End While
dr.Close()
Dim mycomm As SqlDataAdapter = New SqlDataAdapter(mysql, conn)
Dim ds As DataSet = New DataSet()
mycomm.Fill(ds, "base")
DataGrid1.DataSource = ds.Tables("base").DefaultView
DataGrid1.DataBind()
End If
End Sub
'/////////////////////填充yourcheck
Private Sub yourcheck_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles yourcheck.CheckedChanged
Dim i As Integer
For i = 0 To mycheck.Items.Count - 1
If yourcheck.Checked Then
mycheck.Items(i).Selected = True
Else
mycheck.Items(i).Selected = False
End If
Next
End Sub
'///////////////////////提升一般用户为管理员
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
conn.Open()
Dim i As Integer
For i = 0 To mycheck.Items.Count - 1
If mycheck.Items(i).Selected Then
Dim sql_1 As String = "update pwd set term=1 where stu_id=@stu_id and term=0"
Dim comm As SqlCommand = New SqlCommand(sql_1, conn)
comm.Parameters.Add(New SqlParameter("@stu_id", SqlDbType.Int, 4))
comm.Parameters("@stu_id").Value = CheckBoxList1.Items(i).Text
comm.ExecuteNonQuery()
End If
Next
Response.Redirect("boaman.aspx")
End Sub
'///////////////////////降级管理员为一般用户
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
conn.Open()
Dim i As Integer
For i = 0 To mycheck.Items.Count - 1
If mycheck.Items(i).Selected Then
Dim sql_1 As String = "update pwd set term=0 where stu_id=@stu_id and term=1"
Dim comm As SqlCommand = New SqlCommand(sql_1, conn)
comm.Parameters.Add(New SqlParameter("@stu_id", SqlDbType.Int, 4))
comm.Parameters("@stu_id").Value = CheckBoxList1.Items(i).Text
comm.ExecuteNonQuery()
End If
Next
Response.Redirect("boaman.aspx")
End Sub
End Class
当然了,这里面还有好多不足的地方,恳求高手批评指正。
校友录还有一些其它的功能就很简单了,这里就不再探讨了。
贪吃蛇c语言代码
#define N
#include <graphics.h>
#include <stdlib.h>
#include <dos.h>
#define LEFT 0x4b
#define RIGHT 0x4d
#define DOWN 0x
#define UP 0x
#define ESC 0xb
int i,key;
int score=0;/*得分*/
int gamespeed=;/*游戏速度自己调整*/
struct Food
{
int x;/*食物的横坐标*/
int y;/*食物的纵坐标*/
int yes;/*判断是否要出现食物的变量*/
}food;/*食物的结构体*/
struct Snake
{
int x[N];
int y[N];
int node;/*蛇的节数*/
int direction;/*蛇移动方向*/
int life;/* 蛇的生命,0活着,1死亡*/
}snake;
void Init(void);/*图形驱动*/
void Close(void);/*图形结束*/
void DrawK(void);/*开始画面*/
void GameOver(void);/*结束游戏*/
void GamePlay(void);/*玩游戏具体过程*/
void PrScore(void);/*输出成绩*/
/*主函数*/
void main(void)
{
Init();/*图形驱动*/
DrawK();/*开始画面*/
GamePlay();/*玩游戏具体过程*/
Close();/*图形结束*/
}
/*图形驱动*/
void Init(void)
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc");
cleardevice();
}
/*开始画面,左上角坐标为(,),右下角坐标为(,)的围墙*/
void DrawK(void)
{
/*setbkcolor(LIGHTGREEN);*/
setcolor();
setlinestyle(SOLID_LINE,0,THICK_WIDTH);/*设置线型*/
for(i=;i<=;i+=)/*画围墙*/
{
rectangle(i,,i+,); /*上边*/
rectangle(i,,i+,);/*下边*/
}
for(i=;i<=;i+=)
{
rectangle(,i,,i+); /*左边*/
rectangle(,i,,i+);/*右边*/
}
}
/*玩游戏具体过程*/
void GamePlay(void)
{
randomize();/*随机数发生器*/
food.yes=1;/*1表示需要出现新食物,0表示已经存在食物*/
snake.life=0;/*活着*/
snake.direction=1;/*方向往右*/
snake.x[0]=;snake.y[0]=;/*蛇头*/
snake.x[1]=;snake.y[1]=;
snake.node=2;/*节数*/
PrScore();/*输出得分*/
while(1)/*可以重复玩游戏,压ESC键结束*/
{
while(!kbhit())/*在没有按键的情况下,蛇自己移动身体*/
{
if(food.yes==1)/*需要出现新食物*/
{
food.x=rand()%+;
food.y=rand()%+;
while(food.x%!=0)/*食物随机出现后必须让食物能够在整格内,这样才可以让蛇吃到*/
food.x++;
while(food.y%!=0)
food.y++;
food.yes=0;/*画面上有食物了*/
}
if(food.yes==0)/*画面上有食物了就要显示*/
{
setcolor(GREEN);
rectangle(food.x,food.y,food.x+,food.y-);
}
for(i=snake.node-1;i>0;i--)/*蛇的每个环节往前移动,也就是贪吃蛇的关键算法*/
{
snake.x[i]=snake.x[i-1];
snake.y[i]=snake.y[i-1];
}
/*1,2,3,4表示右,左,上,下四个方向,通过这个判断来移动蛇头*/
switch(snake.direction)
{
case 1:snake.x[0]+=;break;
case 2: snake.x[0]-=;break;
case 3: snake.y[0]-=;break;
case 4: snake.y[0]+=;break;
}
for(i=3;i<snake.node;i++)/*从蛇的第四节开始判断是否撞到自己了,因为蛇头为两节,第三节不可能拐过来*/
{
if(snake.x[i]==snake.x[0]&&snake.y[i]==snake.y[0])
{
GameOver();/*显示失败*/
snake.life=1;
break;
}
}
if(snake.x[0]<||snake.x[0]>||snake.y[0]<||
snake.y[0]>)/*蛇是否撞到墙壁*/
{
GameOver();/*本次游戏结束*/
snake.life=1; /*蛇死*/
}
if(snake.life==1)/*以上两种判断以后,如果蛇死就跳出内循环,重新开始*/
break;
if(snake.x[0]==food.x&&snake.y[0]==food.y)/*吃到食物以后*/
{
setcolor(0);/*把画面上的食物东西去掉*/
rectangle(food.x,food.y,food.x+,food.y-);
snake.x[snake.node]=-;snake.y[snake.node]=-;
/*新的一节先放在看不见的位置,下次循环就取前一节的位置*/
snake.node++;/*蛇的身体长一节*/
food.yes=1;/*画面上需要出现新的食物*/
score+=;
PrScore();/*输出新得分*/
}
setcolor(4);/*画出蛇*/
for(i=0;i<snake.node;i++)
rectangle(snake.x[i],snake.y[i],snake.x[i]+,
snake.y[i]-);
delay(gamespeed);
setcolor(0);/*用黑色去除蛇的的最后一节*/
rectangle(snake.x[snake.node-1],snake.y[snake.node-1],
snake.x[snake.node-1]+,snake.y[snake.node-1]-);
} /*endwhile(!kbhit)*/
if(snake.life==1)/*如果蛇死就跳出循环*/
break;
key=bioskey(0);/*接收按键*/
if(key==ESC)/*按ESC键退出*/
break;
else
if(key==UP&&snake.direction!=4)
/*判断是否往相反的方向移动*/
snake.direction=3;
else
if(key==RIGHT&&snake.direction!=2)
snake.direction=1;
else
if(key==LEFT&&snake.direction!=1)
snake.direction=2;
else
if(key==DOWN&&snake.direction!=3)
snake.direction=4;
}/*endwhile(1)*/
}
/*游戏结束*/
void GameOver(void)
{
cleardevice();
PrScore();
setcolor(RED);
settextstyle(0,0,4);
outtextxy(,,"GAME OVER");
getch();
}
/*输出成绩*/
void PrScore(void)
{
char str[];
setfillstyle(SOLID_FILL,YELLOW);
bar(,,,);
setcolor(6);
settextstyle(0,0,2);
sprintf(str,"score:%d",score);
outtextxy(,,str);
}
/*图形结束*/
void Close(void)
{
getch();
closegraph();
}
å¦ä½ç¼è¯SQLite-How To Compile SQLite
SQLiteæ¯ANSI-Cçæºä»£ç ãå¨ä½¿ç¨ä¹åå¿ é¡»è¦ç¼è¯ææºå¨ç ãè¿ç¯æç« æ¯ç¨äºåç§ç¼è¯SQLiteæ¹æ³çæåã
è¿ç¯æç« ä¸å å«ç¼è¯SQLiteçæ¯ä¸ªæ¥éª¤çåé¦ï¼é£æ ·å¯è½ä¼å°é¾å 为æ¯ç§å¼ååºæ¯é½ä¸åãæ以è¿ç¯æç« æè¿°åéè¿°äºç¼è¯Sqliteçååãå ¸åçç¼è¯å½ä»¤å·²ç»ä½ä¸ºä¾åæä¾äºï¼ä»¥ææåºç¨å¼åè è½å¤ä½¿ç¨è¿äºä¾åä½ä¸ºå®æä»ä»¬èªå·±å®å¶çç¼è¯è¿ç¨ççä¸ä¸ªæåãæ¢å¥è¯è¯´ï¼è¿ç¯æç« æä¾äºæ³æ³åè§è§£ï¼èä¸æ¯äº¤é¥åç解å³æ¹æ³ã
èåVSåç¬æºæ件
Sqliteæ¯ç±è¶ è¿ä¸ç¾ä¸ªcæºç æ件以åä¼å¤çç®å½ä¸çèæ¬æ建çãSqliteçå®ç°æ¯çº¯ç²¹çANSI-Cï¼ä½æ¯è®¸å¤Cè¯è¨æºä»£ç æ件æ¯ç±è¾ å©çCç¨åºçææè 转æ¢æ¥çï¼å¹¶ä¸AWKï¼SEDåTCLèæ¬ä¼èåå°å®æçsqliteåºä¸ã对Sqliteæ建éè¦çCç¨åºå转æ¢åå建Cè¯è¨æºç æ¯ä¸ä¸ªå¤æçè¿ç¨ã
为äºç®åè¿äºï¼sqliteä¹éè¿ä¸ä¸ªé¢æå çå并åçæºç æ件ï¼sqlite3.cãè¿ä¸ªå并æ件æ¯ä¸ä¸ªANSI-Cæºç å®ç°æ´ä¸ªSQLiteåºçå¯ä¸æ件ãå并åçæ件æ´å®¹æå¤çãææçä¸è¥¿é½å å«å¨è¿ä¸ä¸ªæ件éï¼æ以å¾å®¹æè¿å ¥ä¸ä¸ªæ´å¤§çCæè C++ç¨åºçæºç æ ãææç代ç çæå转æ¢æ¥éª¤é½å·²ç»å®ç°äºï¼å æ¤æ²¡æè¾ å©çCç¨åºéè¦å»é ç½®ååå¼ï¼ä¹æ²¡æèæ¬éè¦å»è¿è¡ã并ä¸ï¼å æ¤ææåé½å å«å¨ä¸ä¸ªç¿»è¯åå ï¼ç¼è¯å¨å¯ä»¥åæ´å¤é«çº§çä¼åä»èæå5%å°%çæ§è½ãå 为è¿äºåå ï¼èååçæºç æ件sqlite3.c对ææç¨åºæ¥è®²é½æ¯å¼å¾æ¨èçã
æ¨èææçåºç¨ç¨åºä½¿ç¨èåæ件ã
ç´æ¥ä»åç¬çæºç æ件ä¸æ建sqliteå½ç¶å¯ä»¥ï¼ä½æ¯å¹¶ä¸æ¨èã对ä¸äºç¹æ®çåºç¨ç¨åºï¼å¯è½éè¦ä¿®æ¹æ建ç¨åºå»å¤ç使ç¨é£äºä»ç½ç«ä¸ä¸è½½çé¢æ建çæºç æ件ä¸è½å®æçæ åµã对äºè¿äºæ åµï¼æ¨èæ建å使ç¨ä¸ä¸ªå®å¶è¿çå并æ件ãæ¢å¥è¯è¯´ï¼å³ä½¿ä¸ä¸ªå·¥ç¨éè¦ä»¥åç¬çæºç æ件æ建sqliteï¼ä»ç¶æ¨è使ç¨ä¸ä¸ªèååçæºç æ件ä½ä¸ºä¸ä¸ªä¸é´æ¥éª¤ã
ç¼è¯å½ä»¤è¡æ¥å£ï¼CLIï¼
æ建å½ä»¤è¡æ¥å£éè¦ä¸ä¸ªæºç æ件ï¼
sqlite3.c:Sqliteèåçæºç æ件
sqlite3.h:å¹é sqlite3.c以åå®ä¹sqliteçcè¯è¨æ¥å£ç头æ件
shell.c:å½ä»¤è¡æ¥å£ç¨åºæ¬èº«ãè¿ä¸ªcæºç æ件å å«ä¸ä¸ªmain()çä¾ç¨åæ¯è½®å¾ªç¯çç¨æ·è¾å ¥çæ示符并å°è¾å ¥ä¼ ç»sqliteæ°æ®åºå¼æç¨äºå¤çã
ææçä¸è¿°æºç çä¸ä¸ªæ件é½è¢«å å«å¨ä¸è½½é¡µé¢çamalgamation tarballä¸ã
为äºæ建CLIï¼ç®åçå°è¿ä¸ä¸ªæ件æ¾ç½®å¨ç¸åçç®å½ä¸ç¶åä¸èµ·ç¼è¯ä»ä»¬ãç¨MSVCï¼
cl shell.c sqlite3.c -Fesqlite3.exe
å¨unixç³»ç»ä¸ï¼æè å¨windowsä¸ç¨cygwinæè mingw+msysï¼å ¸åçå½ä»¤ä¼æäºåè¿æ ·ï¼
gcc shell.c sqlite3.c -lpthread -ldl
为äºSQLite线ç¨å®å ¨ï¼éè¦pthreadsåºãä½æ¯å 为CLIæ¯ä¸ä¸ªå线ç¨çï¼æ们å¯ä»¥æ示SQLiteæ建ä¸ä¸ªé线ç¨å®å ¨çåºå¹¶å æ¤æ¤ç»¿pthreadsåºï¼
gcc -DSQLITE_THREADSAFE=0 shell.c sqlite3.c -ldl
-ldlåºæ¯å¨æ¯æå¨æè£ è½½æ¶éè¦ï¼ä¾å¦sqlite3_load_extension() æ¥å£åload_extension()
SQL functionãå¦æè¿äºç¹æ§é½ä¸è¦æ±ï¼é£ä¹æ们ä¹å¯ä»¥ä½¿ç¨SQLITE_OMIT_LOAD_EXTENSIONç¼è¯æ¶é´é项忽ç¥ä»ä»¬ã
gcc -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION shell.c sqlite3.c
æ人å¯è½æ³è¦æä¾å ¶ä»çç¼è¯æ¶é´é项(compile-time options)ï¼ä¾å¦SQLITE_ENABLE_FTS3å»å ¨ææ¬æç´¢æè SQLITE_ENABLE_RTREEç¨äºR*æ æç´¢å¼ææ©å±ãèæ人å°æ£å¸¸æå®ä¸äºç¼è¯ä¼åå¼å ³ãï¼é¢ç¼è¯çCLIå¯ä»¥ä»éæ©sqliteç½ç«ä¸ä½¿ç¨â-Osâä¸è½½ä¸æ¥ï¼ææ æ°ç§å¯è½çåæ°å¨è¿éã
å ³é®ç¹å¨è¿éï¼æ建CLIéè¦ç¼è¯ä¸èµ·ä¸¤ä¸ªCè¯è¨æ件ãshell.cæ件å å«å ¥å£çå®ä¹åç¨æ·è¾å ¥çloopï¼èsqliteèåæ件sqlite3.cå å«å®æ´çsqliteåºçå®ç°ã
ç¼è¯TCLæ¥å£
sqliteçtclæ¥å£æ¯ä¸ä¸ªå°ç模å被添å å°ä¸è¬çèåæ件ä¸ãç»ææ¯ä¸ä¸ªæ°çèååçæºç æ件ï¼ç§°ä¹ä¸ºâtclsqlite3.câãè¿ä¸ªæºç æ件æ¯çæä¸ä¸ªå¯ä»¥ä½¿ç¨TCL
loadå½ä»¤å»å è½½å°ä¸ä¸ªæ åçtclshæè wishä¸ï¼æè éçsqliteæ建æåçæä¸ä¸ªåç¬å¯ä¸çtclshçå ±äº«åºæéè¦çãä¸ä¸ªtclçèåçå¯æ¬è¢«å å«å¨ä¸è½½é¡µçTEA
tarballä¸ä½ä¸ºä¸ä¸ªæ件ã
为äºçæä¸ä¸ªlinuxä¸çsqliteçTCL-loadableåº,ä¸é¢çå½ä»¤éè¦æ»¡è¶³ï¼
gcc -o libtclsqlite3.so -shared tclsqlite3.c -lpthread -ldl -ltcl
ä¸å¹¸çæ¯æ建Mac OS X å Windowsçå ±äº«åºå¹¶ä¸æ¯å¦æ¤ç®åã对äºè¿äºå¹³å°æ好使ç¨å å«å¨TEA tarballä¸çconfigureèæ¬åmakefile.
为äºçæä¸ä¸ªåç¬çtclshï¼å¯ä»¥ç¨äºsqliteéæé¾æ¥ï¼ä½¿ç¨å¦ä¸çç¼è¯å¨è°ç¨ï¼
gcc -DTCLSH=1 tclsqlite3.c -ltcl -lpthread -ldl -lz -lm
è¿éçæå·§æ¯-DTCLSH=1é项ãsqliteçTCLæ¥å£æ¨¡åå å«ä¸ä¸ªmainçè¿ç¨ï¼ç¨äºåå§åä¸ä¸ªTCL解éå¨å¹¶å¨ä»¥-DTCLSH=1ç¼è¯åè¿å ¥å°ä¸ä¸ªå½ä»¤è¡loopãä¸è¿°å½ä»¤å¯ä»¥å·¥ä½å¨LinuxåMac
OS X,è½ç¶ææ¶å¯è½éè¦ä¾èµäºå¹³å°è°æ´åºé项以åç¼è¯çTCLçåªä¸ä¸ªçæ¬ã
æ建èåæ件
ä¸è½½é¡µæä¾çsqliteèåæ件ççæ¬å¯¹å¤§å¤æ°ç¨æ·æ¥è¯´æ¯è¶³å¤çãç¶èï¼ä¸äºå·¥ç¨å¯è½æ³è¦æè éè¦æ建ä»ä»¬èªå·±çèåæ件ãä¸ä¸ªå¸¸è§çæ建ä¸ä¸ªå®å¶çèåæ件ççç±æ¯ä¸ºäºä½¿ç¨ç¹å®çcompile-time optionsæ¥å®å¶sqliteåºãåæ³sqliteèåæ件ä¸å å«äºè®¸å¤C代ç ç±è¾ å©ç¨åºåèæ¬çæã许å¤çç¼è¯æ¶é´é项影åè¿ä¸æå£ä»£ç èä¸å¿ é¡»å¨èåæ件ç»è£ åæä¾ç»ä»£ç çæå¨ãè¿ä¸ç³»åå¿ é¡»ä¼ ç»ä»£ç çæå¨çç¼è¯æ¶é´ç¸å ³çé项ä¼ä½¿å¾sqliteçåå¸çæ¬åä¸ç¸åï¼ä½æ¯å¨åè¿è¾¹æç« çæ¶åï¼ä»£ç çæå¨éè¦ç¥éçè¿ç»é项å æ¬ï¼
SQLITE_ENABLE_UPDATE_DELETE_LIMIT
SQLITE_OMIT_ALTERTABLE
SQLITE_OMIT_ANALYZE
SQLITE_OMIT_ATTACH
SQLITE_OMIT_AUTOINCREMENT
SQLITE_OMIT_CAST
SQLITE_OMIT_COMPOUND_SELECT
SQLITE_OMIT_EXPLAIN
SQLITE_OMIT_FOREIGN_KEY
SQLITE_OMIT_PRAGMA
SQLITE_OMIT_REINDEX
SQLITE_OMIT_SUBQUERY
SQLITE_OMIT_TEMPDB
SQLITE_OMIT_TRIGGER
SQLITE_OMIT_VACUUM
SQLITE_OMIT_VIEW
SQLITE_OMIT_VIRTUALTABLE
为äºæ建ä¸ä¸ªå®å¶çèåæ件ï¼å ä¸è½½åå§çç¬ç«æºç æ件å°ä¸ä¸ªunixæè ç±»unixå¼åå¹³å°ãç¡®å®è·åçåå§æºç æ件ä¸æ¯âé¢ç¼è¯è¿çæºæ件âãä»»ä½äººé½å¯ä»¥éè¿å°ä¸è½½é¡µæè ç´æ¥ä»configuration management system.è·åå®æ´çä¸å¥åå§æºç æ件ã
å设sqliteæºç æ 被åå¨ä¸ä¸ªå为âsqliteâçç®å½ä¸ã计åæ建ä¸ä¸ªå¹³è¡ç®å½ä¸çå为âbldâçèåæ件ãé¦å éè¿è¿è¡sqliteæºç æ ç§çconfigureèæ¬è¿è¡æè éè¿å¶ä½ä¸ä»½æºç æ 顶å±ççmakfile模æ¿çä¸ä»½ï¼æ¥æ建ä¸ä¸ªåéçmakefile.ç¶åæå¨ç¼è¾è¿ä¸ªMakfileå»å å«éè¦çç¼è¯æ¶é´ç¸å ³çé项ãæç»è¿è¡ï¼
make sqlite3.c
å¨windowsä¸ä½¿ç¨MSVC:
nmake /f Makefile.msc sqlite3.c
sqlite3.cçmake
targetä¼èªå¨æé ä¸è¬çâsqlite3.câå并çæºç æ件ï¼ä»¥åå®ç头æ件âsqlite3.hâï¼åå å«TCLæ¥å£çèåæºç æ件âtclsqlite3.câãä¹åï¼éè¦çæ件å¯ä»¥è¢«æ·è´å°æ件ç®å½ä¸ç¶åæ ¹æ®ä¸è¿°å¾åçè¿ç¨ç¼è¯ã
æ建ä¸ä¸ªwindowsçå¨æé¾æ¥åºDLL
为äºå¨windowsæ建ä¸ä¸ªsqliteçdll使ç¨ï¼é¦å è·å对åºçèåè¿çæºç æ件ï¼sqlit3.cåsqlite.hãè¿äºå¯ä»¥ä»SQLite websiteä¸ä¸è½½æè åä¸è¿°åç¥çä¸æ ·å»å®å¶çæã
使ç¨å·¥ä½ç®å½ä¸çæºç æ件ï¼ä¸ä¸ªdllå¯ä»¥å¨msvcä¸ä½¿ç¨å¦ä¸å½ä»¤çæï¼
cl sqlite3.c -link -dll -out:sqlite3.dll
ä¸è¿°å½ä»¤éè¦è¿è¡å¨msvcçMSVC Native Tools Command
Prompt.å¦ä½ä½ å·²ç»å¨æºå¨ä¸å®è£ äºmsvcï¼ä½ å¯è½æå¤ä¸ªçæ¬çè¿ç§å½ä»¤æ示符ï¼é对äºxåxçèªå¸¦æ建çï¼æè 交åç¼è¯å°ARMçãä¾èµè¦æ±çDLLå»ä½¿ç¨å¯¹åºåéçå½ä»¤æç¤ºç¬¦å·¥å ·ã
å¦æ使ç¨MinGWç¼è¯å¨ï¼å½ä»¤æ¯è¿æ ·çï¼
gcc -shared sqlite3.c -o sqlite3.dll
注æMinGWåªçæä½çdllãå¦æä¸ä¸ªåå¼çMinGWå·¥ç¨å¯ä»¥ç¨æ¥çæä½çdllãå¯ä»¥æ¨æå ¶å½ä»¤è¡è¯æ³æ¯ç±»ä¼¼çãéè¦æ³¨æçæ¯æè¿çMSVCççæ¬çæçDLLså¯è½ä¸è½å·¥ä½å°WinXPæè æ´æ©çæ¬çwindowsä¸ãå æ¤ä¸ºäºæ大é度çå ¼å®¹ä½ ççæçdllï¼æ¨èMinGWãä¸ä¸ªå¥½çç»éªæ³åæ¯ä½¿ç¨MinGWå»çæä½çdllsï¼ä½¿ç¨msvcå»çæä½çdllsã