Support and General Use > Audio Playback, Database and Playlists
SQLite plugin
JamClerk:
I am trying to implement a sqlite plugin - using the patch provided here: http://www.rockbox.org/tracker/task/8852
applying the patch was successful but now getting an error during 'make':
LD sqlite3test.rock
/home/ubuntu/Desktop/rockbox/rockbox/testSim/apps/plugins/sqlite3test.o: In function `exec':
sqlite3test.c:(.text+0xfc): undefined reference to `sqlite3_exec'
sqlite3test.c:(.text+0x10c): undefined reference to `sqlite3_free'
/home/ubuntu/Desktop/rockbox/rockbox/testSim/apps/plugins/sqlite3test.o: In function `plugin_start':
sqlite3test.c:(.text+0x130): undefined reference to `sqlite3_open'
sqlite3test.c:(.text+0x140): undefined reference to `sqlite3_close'
collect2: ld returned 1 exit status
make: *** [/home/ubuntu/Desktop/rockbox/rockbox/testSim/apps/plugins/sqlite3test.rock] Error 1
I'm new to developing in c and rockbox so anyone help me out here, thanks
sqlite3text.c looks like this:
--- Code: ---#include "plugin.h"
#include "sqlite3.h"
#ifdef ROCKBOX_HAS_LOGF
#define LOGF_ENABLE
#define logf rb->logf
#else
#define logf(f,args...) DEBUGF(f"\n",##args)
#endif
static int callback(void *NotUsed, int argc, char **argv, char **azColName)
{
int fd = rb->open("/out", O_CREAT|O_WRONLY|O_APPEND);
char buf[512];
int i, ret;
for(i=0; i<argc; i++){
rb->snprintf(buf, sizeof(buf), "%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
ret = rb->write(fd, buf, rb->strlen(buf));
}
rb->close(fd);
return 0;
}
static int exec(sqlite3 *db, const char *command)
{
char *zErrMsg = 0;
int rc = sqlite3_exec(db, command, callback, 0, &zErrMsg);
if (zErrMsg) {
logf("%s", zErrMsg);
}
if (rc!=SQLITE_OK) {
sqlite3_free(zErrMsg);
}
return rc;
}
/* this is the plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
(void)parameter;
int rc;
sqlite3 *db;
rc = sqlite3_open("/test.db", &db);
if (rc)
{
sqlite3_close(db);
return PLUGIN_ERROR;
}
logf("DB opened");
rc = exec(db, "create table tbl1(one varchar(10), two smallint);");
rc = exec(db, "insert into tbl1 values('hello!',10);");
rc = exec(db, "insert into tbl1 values('goodbye', 20);");
rc = exec(db, "select * from tbl1;");
return PLUGIN_OK;
}
--- End code ---
gevaerts:
Was applying the patch really successful? When I try, I get errors applying apps/plugins/lib/SOURCES and apps/plugins/SOURCES.
Also, did you get sqlite3.c and sqlite3.h as described?
Wich revision are you using? A quick test shows that for a current checkout you'll need to fix at least changed handling of the rb struct (i.e. remove all extern declatations in the new code) and replace uses of strncpy by strlcpy (after checking if it's a straight replacement), get rid of the MEM_FUNCTION_WRAPPERS() line, remove PLUGIN_HEADER, and change the plugin_start() function to the new form. After all that it builds for me.
JamClerk:
wel i did get those two errors, but does updating the SOURCES file manually to include the patch not cure this?
i have the sqlite3.c/h downloaded and extracted into apps/plugins/lib
how do i check which revision im using? only started working with rockbox a week ago so should i be up to date?
if you look at the code i pasted in origional question you will see i already changed handling of struct and removed plugin_header, and updated the plugin_start function
apps/plugins/lib/sqlite3_aux.h and apps/plugins/lib/rockbox_vfs.c don't exist, is this because of the errors when applying patch?
thanks
saratoga:
--- Quote from: JamClerk on July 23, 2012, 09:20:46 AM ---apps/plugins/lib/sqlite3_aux.h and apps/plugins/lib/rockbox_vfs.c don't exist, is this because of the errors when applying patch?
--- End quote ---
Looks like they're in the patch, so if you don't have them, its probably because the patch didn't apply.
JamClerk:
have all required header files now created and rockbox built successfully, but when i put in on my sansa its full of problems:
my files only displays folders, not the music/ video or image files contained within the folders
songs are available through database but selecting one to play quickly flicks through entire list of songs without playing them
plugins lists show a 'no files' message, but they are all there in folders when plugged in to usb
any ideas what i could have broken?
thanks
Navigation
[0] Message Index
[#] Next page
Go to full version