[英]C++ SQLite3 Error - undefined reference to `sqlite3_open'
Im using CodeBlocks and Im trying to execute this simple code:我正在使用 CodeBlocks 并尝试执行这个简单的代码:
#include <iostream>
#include <sqlite3.h>
int main(int argc, char** argv)
{
sqlite3* DB;
int exit = 0;
exit = sqlite3_open("example.db", &DB);
if (exit) {
std::cerr << "Error open DB " << sqlite3_errmsg(DB) << std::endl;
return (-1);
}
else
std::cout << "Opened Database Successfully!" << std::endl;
sqlite3_close(DB);
return (0);
}
But I receives this errors:但是我收到这个错误:
||=== Build: Debug in test (compiler: Cywin) ===|
obj\Debug\main.o||In function `main':|
C:\Users\xxxx\Desktop\test\test\main.cpp|8|undefined reference to `sqlite3_open'|
C:\Users\xxxx\Desktop\test\test\main.cpp|11|undefined reference to `sqlite3_errmsg'|
C:\Users\xxxx\Desktop\test\test\main.cpp|16|undefined reference to `sqlite3_close'|
||error: ld returned 1 exit status|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
I've moved Sqlite3.c and Sqlite3.h to MinGW include folder, I imagine that its a link error, if anyone can help me it could be perfect.我已经将 Sqlite3.c 和 Sqlite3.h 移动到 MinGW 包含文件夹,我想它是一个链接错误,如果有人可以帮助我,它可能是完美的。
Sqlite3.c is a source file. Sqlite3.c 是一个源文件。 It has nothing to do in the MinGW include folder.
它与 MinGW 包含文件夹无关。 To add Sqlite3.c to your project you can take a look at:
要将 Sqlite3.c 添加到您的项目中,您可以查看:
http://wiki.codeblocks.org/index.php/Creating_a_new_project#Adding_a_pre-existing_file http://wiki.codeblocks.org/index.php/Creating_a_new_project#Adding_a_pre-existing_file
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.