I am new to programming and have just started to learn C. I would like to use SQLite3 in a c program but am having a hard time setting up the library. I am using old fashion command line interface to compile and run my programs. I am using gcc. I also tried using CodeBlocks and have spent alot of time researching on how to get this to work but no success! I found a C and SQLite3 tutorial but it doesn't explain this simple concept of setting up the SQLite library with the GCC compliler. I also found another tutorial but it too doesn't explain how to set up the libary with the GCC compiler.
So far I have a simple program called "testsql.c" and this is all I would like to get working:
#include <sqlite3.h>
#include <stdio.h>
int main() {
printf("%s\n", sqlite3_libversion());
return 0;
}
I am using the following gcc command to compile the program:
C:\Users\qwa\Desktop\testsql>gcc testsql.c -o testsql -lsqlite3
The output is always this error:
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsqlite3
collect2.exe: error: ld returned 1 exit status
Now I have been on SQLite's download webpage and have downloaded the following files and have tried placing them under the MinGW\bin and MinGW\include:
The Amalgamation zip file:
shell.c
sqlite3.c
sqlite3.h
sqlite3ext.h
I also downloaded the dll zip file hoping I could figure out how to link it with CodeBlocks but was unsuccessful. That zip file came with these files:
sqlite3.def
sqlite3.dll
I think my problem is that I just don't know how to make a connection between the SQLite3 libraries and the gcc compiler. I feel like this is such a noob question but I have been struggling :(
Any help would be extremely appreciated!!! To summarize, I just want a SQLite database connection setup with a simple C program.
EDIT: based on the first comment, I just used the following command:
gcc testsql.c -o testsql -LC:\sqlite3\sqlite3.dll
and the result I got was:
C:\Users\qwa\AppData\Local\Temp\ccMjAu3h.o:testsql.c:(.text+0xf):undefined reference to `sqlite3_libversion'
collect2.exe: error: ld returned 1 exit status
any ideas?