使用sqlite 时,函数编译的问题

sdqh002 发布于 2012/03/21 11:07
阅读 680
收藏 0
根据源码包里修改一个SSH server,将使用sqlite来验证用户名,密码。
check(unsigned char *username, unsigned int userlen){
	TRACE(("enter checkusername"))
	if (userlen > MAX_USERNAME_LEN) {
		return DROPBEAR_FAILURE;
	}
	char name[64];

	sqlite3 *db=NULL;
    char *zErrMsg =0;        
    int rc;
    rc=sqlite3_open("user.db",&db);
    if(rc)
    {
        fprintf(stderr,"Can't open database: %s\n",sqlite3_errmsg(db));
		sqlite3_close(db);
		TRACE(("leave checkusername: user '%s' doesn't exist", username))
		dropbear_log(LOG_WARNING,"Login attempt for nonexistent user from %s",svr_ses.addrstring);
		send_msg_userauth_failure(0, 1);
		return DROPBEAR_FAILURE;      
        exit(1);
    }
    else
        { 
           
			char sql[128];
            sprintf(sql, "SELECT username from userinfo where name='%s'", username);
            rc = sqlite3_exec(db,sql,return_checkusername,NULL,&zErrMsg);
			 printf("open user.db successfully!\n");
        }
    sqlite3_close(db);
    return 0;
}
我在进行整体编译的时候出现错误:
svr-auth.c: In function ‘checkpasswd’:
svr-auth.c:491: error: ‘sqlite3’ undeclared (first use in this function)
svr-auth.c:491: error: (Each undeclared identifier is reported only once
svr-auth.c:491: error: for each function it appears in.)
svr-auth.c:491: error: ‘db’ undeclared (first use in this function)
svr-auth.c:494: warning: implicit declaration of function ‘sqlite3_open’
svr-auth.c:497: warning: implicit declaration of function ‘sqlite3_errmsg’
svr-auth.c:498: warning: implicit declaration of function ‘sqlite3_close’
svr-auth.c:506: warning: implicit declaration of function ‘sqlite3_exec’
svr-auth.c: At top level:
svr-auth.c:512: warning: return type defaults to ‘int’
svr-auth.c: In function ‘check’:
svr-auth.c:519: error: ‘sqlite3’ undeclared (first use in this function)
svr-auth.c:519: error: ‘db’ undeclared (first use in this function)
svr-auth.c:517: warning: unused variable ‘name’
make: *** [svr-auth.o] Error 1
根据网上提供的资料,添加了环境变量,修改了Makefile里的编译选项:
CFLAGS+=-I. -I$(srcdir) $(CPPFLAGS) -Os -W -Wall -lsqlite3  -L/home/sqlite/lib -I/home/sqlite/include
1.请问还有哪里需要修改?
2.我现在用的是在系统里安装好的sqlite库,如果我要是使用本地,包里的库,如何编译。

加载中
返回顶部
顶部