On Sat, 5 Apr 2008 18:16:47 +0200 (CEST)
dark0s dark0s <[EMAIL PROTECTED]> wrote:
> Hi all, I am newbye in sqlite programming.
> I written a little C program to begin with sqlite, and I posted it below:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <sqlite3.h>
>
> void main() {
>
> int rc, i;
> sqlite3* db;
> sqlite3_stmt* stmt;
> char* sql;
> const char* tail;
>
> rc = sqlite3_open("prova.db", &db);
> if (rc) {
> fprintf(stderr, "E' impossibile aprire il file %s\n", sqlite3_errmsg(db));
> sqlite3_close(db);
> exit(1);
> }
>
> sql = "create table modulo(id, nome, classe, istanza);";
> rc = sqlite3_prepare(db, sql, strlen(sql), &stmt, &tail);
> if (rc != SQLITE_OK) {
> fprintf(stderr, "Errore SQL: %s\n", sqlite3_errmsg(db));
> }
>
> rc = sqlite3_step(stmt);
>
> while (rc == SQLITE_ROW) {
> for (i = 0; i < sqlite3_column_count(stmt); i++)
> fprintf(stderr, "'%s' ", sqlite3_column_text(stmt, i));
> fprintf(stderr, "\n");
> rc = sqlite3_step(stmt);
> }
>
> sqlite3_finaqlize(stmt);
> sqlite3_close(db);
>
> }
>
> So, when I compile above program the result is:
>
> bash-3.1# gcc CreaDB.c -o CreaDB
> CreaDB.c: In function 'main':
> CreaDB.c:21: warning: incompatible implicit declaration of built-in function
> 'strlen'
> CreaDB.c:5: warning: return type of 'main' is not 'int'
> CreaDB.c:41:3: warning: no newline at end of file
> /tmp/ccs8L4Zw.o: In function `main':
> CreaDB.c:(.text+0x1f): undefined reference to `sqlite3_open'
> CreaDB.c:(.text+0x37): undefined reference to `sqlite3_errmsg'
> CreaDB.c:(.text+0x5e): undefined reference to `sqlite3_close'
> CreaDB.c:(.text+0xa4): undefined reference to `sqlite3_prepare'
> CreaDB.c:(.text+0xbc): undefined reference to `sqlite3_errmsg'
> CreaDB.c:(.text+0xe3): undefined reference to `sqlite3_step'
> CreaDB.c:(.text+0x103): undefined reference to `sqlite3_column_text'
> CreaDB.c:(.text+0x12d): undefined reference to `sqlite3_column_count'
> CreaDB.c:(.text+0x154): undefined reference to `sqlite3_step'
> CreaDB.c:(.text+0x16c): undefined reference to `sqlite3_finaqlize'
> CreaDB.c:(.text+0x17b): undefined reference to `sqlite3_close'
> collect2: ld returned 1 exit status
>
>
> What is the problem?
>
> Thanks,
> savio
>
>From what I can see you have to pass sqlite3.c to gcc when compiling your
>program:
gcc CreaDB.c sqlite3.c -o CreaDB
Amit
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users