Reputation: 11
I am creating a word list searcher in C for my program using sqlite3 but I've got these errors .
I tried whatever I knew but it didn't fixed. I guess the problem is in my join function but I am not sure.
code :
bool *gb_wordlist_add_to_list (gbwordlist *word_list,char *str)
{
int sql_error;
char *error_massage;
if (gb_wordlist_in_list (word_list,str))
{
sql_error = sqlite3_execute(word_list->database, gb_wordlist_join(ADD_TO_TABLE_COMMAND"\'",str,"\';"),
NULL ,NULL, &error_massage);
if( sql_error!=SQLITE_OK )
{
fprintf(stderr, "SQL error: %s\n", error_massage);
sqlite3_free(error_massage);
return 0;
}
}
else
return 0;
}
char *gb_wordlist_join (char *s1,char *s2,char *s3){
char *s;
s = malloc(strlen(s1) + strlen(s2) + strlen(s3) + 1);
if(s)
{
strcpy(s,s1);
strcat(s,s2);
strcat(s,s3);
}
return s;
}
error:
gb-sql.o: In function `gb_wordlist_remove_from_list':
/home/reza/Project/GB/Search algorithm/Source/gb-search/src/gb-sql.c:104: undefined reference to `sqlite3_execute'
Also my full codes are here. Thanks a lot!
Upvotes: 0
Views: 500
Reputation: 11395
The reason you are getting undefined reference to sqlite3_execute
is well there is no such function as part of library. You probably meant to use sqlite3_exec
(which use have used in some parts of the code).
Side Notes:
gb_wordlist_callback
is returning int
but has been declared to return int*
. You should change the return type to int
to match the expected parameters to be passed to sqlite3_exec
(after modifying from sqlite3_execute
)sqlite3_exec
(after modifying from sqlite3_execute
) is expected to be void*
so existance
should be &existance
-Wall -Wextra
compiler options & fix all the warnings. It is good practice. Hope this helps!
Upvotes: 1