HI now that i had installed sqlite on my mini i had put a simple data base on it, now i want to read that database by a simple programm made by C languaje, and using diferents examples i have found but when i compiled them its shows me this mistake: hello.c:(.text+0x54): undefined reference to `sqlite3_open' hello.c:(.text+0x13c): undefined reference to `sqlite3_exec' hello.c:(.text+0x1a4): undefined reference to `sqlite3_exec' hello.c:(.text+0x20c): undefined reference to `sqlite3_exec' hello.c:(.text+0x278): undefined reference to `sqlite3_prepare_v2' hello.c:(.text+0x2ac): undefined reference to `sqlite3_column_count' hello.c:(.text+0x2c0): undefined reference to `sqlite3_step' hello.c:(.text+0x2f8): undefined reference to `sqlite3_column_text' hello.c:(.text+0x310): undefined reference to `sqlite3_column_name' hello.c:(.text+0x36c): undefined reference to `sqlite3_close' i dont know if i have to install something on my compiller can anybody help me!! the code im using its this: #include <stdio.h> #include <sqlite3.h> static int callback(void *NotUsed, int argc, char **argv, char **azColName){ int i; for(i=0; i<argc; i++){ printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL"); } printf("\n"); return 0; } int main(int argc, char **argv){ sqlite3 *db; char *zErrMsg = 0; int rc; if( argc!=3 ){ fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]); exit(1); } rc = sqlite3_open(argv[1], &db); if( rc ){ fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg); if( rc!=SQLITE_OK ){ fprintf(stderr, "SQL error: %s\n", zErrMsg); sqlite3_free(zErrMsg); } sqlite3_close(db); return 0; } thanks
sqlite and C languaje
It seems that it can't find the sqlite3.h (this c header file must also be in the same directory as your source code you are compiling).
Jay thanks for your fast answer my sqlite3.h is locate on: /usr/local/arm/4.3.2/lib/gcc/arm-none-linux-gnueabi/4.3.2/include also i pasted on route where im compiling but it shows me the same mistake
You should take a look at the -l flags on compilation. Probably you should add the "-lsqlite3" on compilation command line, then your program will be linked with libsqlite3.so (which contains the sqlite3_xxx functions).
try: arm-linux-g++ -o sqliteTestProgram main.cpp -L/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/lib -lsqlite3 or something like that. You should look for "undefined reference" at google befor post it here.
thats what i have found on others forums but im very new on this topic, when i compiled my program i did it bye this instrution: arm-linux-gcc -lsqlite3.so -o hello hello.c thats what you tellme right? but im having this mistake: /usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm -none-linux-gnueabi/bin/ld: cannot find -lsqlite3 collect2: ld returned 1 exit status now im copy that files on that folder but i have the same problem: /usr/local/arm/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm -none-linux-gnueabi/bin/ld: cannot find -lsqlite3 collect2: ld returned 1 exit status im not very sure about the right place to paste the libsqlite3.so or do i have to make something else? thanks
i forgot i modify the hello example (the one who brings the cd) my make file its this: CROSS=arm-linux- all: hello hello: $(CROSS)gcc -o hello hello.c clean: @rm -vf hello *.o *~ maybe i have to change something.
hi again i could compile my program the comand line was this: arm-linux-gcc -o filename filename.c -I include libsqlite3.s0 this file "libsqlite3.s0" has to be on the folder where im doing my compilation i hope this can be useful for someone else thanks!!
to avoid "cannot find -lsqlite3" You must put libsqlite3.so under /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/lib. Using the -l option with "sqlite3" the compiler will look for libsqlite3.so (take a look at gcc manual).
Eduardo, i tried what you tell: You must put libsqlite3.so under /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/lib. and tried to compiled with this instrution: arm-linux-gcc -lsqlite3.so -o hello hello.c it throws me the same mistake but when i compiled with this arm-linux-gcc -o hello hello.c -I include libsqlite3.so it compiles well, and creates me the file althought i dont have check it yet.
There is no need for a sqlite.so file you can embed the complete sqlite source code in your project. There is a single sqlite file source which can include in your projects make file. You can dowwnload it directly from http://www.sqlite.org/sqlite-amalgamation-3_6_23_1.zip or http://www.sqlite.org/download.html check the amalgamation source package to know more about amalgamation source package read http://www.sqlite.org/amalgamation.html regards --fatbrain