对于如下使用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: %s\n",sqlite3_errmsg(db));
exit(0);
}else{
fprintf(stderr,"Opened database successfully\n");
}
sqlite3_close(db);
}
如果直接编译
gcc test_sqlite.cpp -o test_sqlite
会发生如下错误
ld: symbol(s) not found for architecture x86_64
clang: error: linker command Failed with exit code 1 (use -v to see invocation)