错误:未定义引用`sqlite3_open' [英] Error: undefined reference to `sqlite3_open'
本文介绍了错误:未定义引用`sqlite3_open'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想开始使用SQLite的C ++ API。
I'm trying to get started with the C++ API for SQLite.
#include <iostream>
#include <sqlite3.h>
using namespace std;
int main()
{
sqlite3 *db;
if (sqlite3_open("ex1.db", &db) == SQLITE_OK)
cout << "Opened db successfully\n";
else
cout << "Failed to open db\n";
return 0;
}
使用命令g ++ main.cpp进行编译时会出现以下错误:
Compiling this using the command "g++ main.cpp" gives the following error:
/tmp/ccu8sv4b.o: In function `main':
main.cpp:(.text+0x64): undefined reference to `sqlite3_open'
collect2: ld returned 1 exit status
出错了?没有sqlite3正确安装在服务器上我正在编译这个?
What could have gone wrong? Hasn't sqlite3 properly installed in the server I'm compiling this in?
推荐答案
您需要链接sqlite3库您的计划:
You need to link the sqlite3 library along with your program:
g++ main.cpp -lsqlite3
这篇关于错误:未定义引用`sqlite3_open'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文