English 中文(简体)
qlite3 图书馆未界定的参考错误
原标题:sqlite3 library undefined reference error

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.

法典:

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 错误: %s
", 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;
}

错误:

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 

我的全文是here。 感谢很多!

最佳回答

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:

  1. The function 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)
  2. The 4th parameter passed to sqlite3_exec (after modifying from sqlite3_execute) is expected to be void* so existance should be &existance
  3. You have quite a few functions with mismatch between return type declared and the actual return type returned from the function.
  4. Compile your code with -Wall -Wextra compiler options & fix all the warnings. It is good practice.

希望这一帮助!

问题回答

暂无回答




相关问题
Simple JAVA: Password Verifier problem

I have a simple problem that says: A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string ...

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

String initialization with pair of iterators

I m trying to initialize string with iterators and something like this works: ifstream fin("tmp.txt"); istream_iterator<char> in_i(fin), eos; //here eos is 1 over the end string s(in_i, ...

break a string in parts

I have a string "pc1|pc2|pc3|" I want to get each word on different line like: pc1 pc2 pc3 I need to do this in C#... any suggestions??

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签