Though there are a few earlier posts on this issue, I still can't find any right solution - any help is appriciated.
I followed this instruction and took the below steps for installation:
- Downloaded precompiled binaries for Windows (sqlite-dll-win32-x86-3240000.zip) form sqlite.org/download, and extracted to "C:\sqlite" folder
- Downloaded sqlite-shell-win32 (sqlite-tools-win32-x86-3240000.zip) form the same download page, and extracted to the same "C:\sqlite" folder. This folder now contains sqlite3.def, sqlite3.dll and sqlite3.exe files.
- Added "C:\sqlite" in my PATH environment variable and the
sqlite3command from my project folder "C:\proj" now works.
I then followed this instruction and to run the program:
Code (test.c) saved under "C:\proj" :
#include <stdio.h>
#include <sqlite3.h>
int main(int argc, char* argv[]) {
sqlite3 *db;
char *zErrMsg = 0;
int rc;
rc = sqlite3_open("test.db", &db);
if( rc ) {
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
return(0);
} else {
fprintf(stderr, "Opened database successfully\n");
}
sqlite3_close(db);
}
In addition, since above code uses #include <sqlite3.h>, I downloaded sqlite-amalgamation-3240000.zip and extracted the "sqlite3.h" file to the same "C:\sqlite" location.
Command executed from "C:\proj":
gcc test.c -o test -I\sqlite -l sqlite3
But I am getting below error:
C:/prg/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lsqlite3
collect2.exe: error: ld returned 1 exit status
What am I doing wrong?