I'm working with a cocos2dx c++ android project that I compile with Eclipse (java edition). Everything has worked great until I try to use sqlite3.
I'm pretty sure the code is correct.
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);
I get these errors
"undefined reference to 'sqlite3_get_table'"
"undefined reference to 'sqlite3_open'"
I had a similar problem with the win32 build and that was solved by adding the sqlite library in Visual Studio. Guess it's the similar problem now but I have no idea how to solve that in Eclipse?