【发布时间】:2015-05-03 08:43:44
【问题描述】:
我正在使用我用 Eclipse(java 版)编译的 cocos2dx c++ android 项目。 在我尝试使用 sqlite3 之前,一切都很好。
我很确定代码是正确的。
sqlite3 *pdb = NULL;
int result;
std::string path = FileUtils::getInstance()->getWritablePath();
path.append("mydb.db");
FILE* file = fopen(path.c_str(), "r");
if (file == nullptr) {
CCLOG("no such file");
long size = 0;
const char* data = (char*) FileUtils::getInstance()->getFileData("mydb.db", "rb", &size);
file = fopen(path.c_str(), "wb");
fwrite(data, size, 1, file);
CC_SAFE_DELETE_ARRAY(data);
}
result = sqlite3_open(path.c_str(),&pdb);
if (result != SQLITE_OK)
CCLOG("OPEN FAILED");
else
CCLOG("OPEN WORKED");
char **re;
int r,c;
sqlite3_get_table(pdb,"select * from mytable", &re, &r, &c, NULL);
CCLOG("num of rows is %d, num of columns is %d", r, c);
我收到这些错误
“对'sqlite3_get_table'的未定义引用”
“对'sqlite3_open'的未定义引用”
我在 win32 版本中遇到了类似的问题,通过在 Visual Studio 中添加 sqlite 库解决了这个问题。 猜猜现在是类似的问题,但我不知道如何在 Eclipse 中解决这个问题?
【问题讨论】:
-
嘿,谢谢,但据我了解,它仅用于添加 Jar 库?
-
AFAIK,不仅是 jars,还可以添加所有支持的库类型。
-
我下载了一个 sqlite jar 库来尝试该解决方案,但这并没有解决我的问题,所以似乎还有其他问题。
标签: android c++ eclipse cocos2d-x undefined-reference