Using SQLite3 in a C program - Simple setup issue
<p>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 <a href="http://www.tutorialspoint.com/sqlite/sqlite_c_cpp.htm" rel="nofollow">C and SQLite3 tutorial</a> 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.</p>

<p>So far I have a simple program called "testsql.c" and this is all I would like to get working: </p>

<pre><code>#include &lt;sqlite3.h&gt;
#include &lt;stdio.h&gt;

int main() {

printf("%s\n", sqlite3_libversion()); 

return 0;
}
</code></pre>

<p>I am using the following gcc command to compile the program:</p>

<pre><code> C:\Users\qwa\Desktop\testsql&gt;gcc testsql.c -o testsql -lsqlite3
</code></pre>

<p>The output is always this error:</p>

<pre><code> c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lsqlite3
 collect2.exe: error: ld returned 1 exit status
</code></pre>

<p>Now I have been on <a href="http://www.sqlite.org/download.html" rel="nofollow">SQLite's download webpage</a> and have downloaded the following files and have tried placing them under the MinGW\bin and MinGW\include:</p>

<pre><code> The Amalgamation zip file:
 shell.c
 sqlite3.c
 sqlite3.h
 sqlite3ext.h
</code></pre>

<p>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:</p>

<pre><code> sqlite3.def
 sqlite3.dll
</code></pre>

<p>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 :( </p>

<p>Any help would be extremely appreciated!!! To summarize, I just want a SQLite database connection setup with a simple C program.</p>

<p><strong>EDIT:</strong> based on the first comment, I just used the following command: </p>

<pre><code>  gcc testsql.c -o testsql -LC:\sqlite3\sqlite3.dll
</code></pre>

<p>and the result I got was:</p>

<pre><code> 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
</code></pre>

<p>any ideas?</p>