SQLite C/C++ 编译
发布时间:2020-12-12 19:38:44 所属栏目:百科 来源:网络整理
导读:对于如下使用SQLite 的C/C++程序, #include stdio.h #include sqlite3.h int main( int argc, char * argv[]){ sqlite3 *db; char *zErrMsg = 0 ; int rc; rc = sqlite3_open( "test.db" ,db); if ( rc ){ fprintf (stderr, "Can't open database: %sn" ,s
对于如下使用SQLite 的C/C++程序, #include <stdio.h>
#include <sqlite3.h>
int main(int argc,char* argv[])
{
sqlite3 *db;
char *zErrMsg = 0;
int rc;
rc = sqlite3_open("test.db",&db);
if( rc ){
fprintf(stderr,"Can't open database: %sn",sqlite3_errmsg(db));
exit(0);
}else{
fprintf(stderr,"Opened database successfullyn");
}
sqlite3_close(db);
}
如果直接编译 会发生如下错误 ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
起原因是没有将SQLite的lib链接进来。解决方法如下:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |