Update:  ok this is working in cygwin, so maybe my GCC compiler on the windows 
side cmd.exe side is all higgly piggly?

on windows cmd.exe whereis gcc shows gcc is at:
\mingw\bin\gcc.exe

whereis isn't in my current cygwin install. 




On Thursday, July 10, 2014 4:17 PM, Jonathan Leslie <jlesli...@yahoo.com> wrote:
 

>
>
>Hey folks, I'm fresh off the boat with sqlite, but I'm an old-timer C 
>programmer on Unix.  I have to work on a window's 7 x64 for this project, and 
>I also for the first time have to use SQL and I want to use SQL using C, gcc, 
>and SQLITE.   So I went to the website and downloaded:
>
>
> Directory of C:\jon\txt\sceptre\SQLite Download Page_files
>
>
>140703  03:40 PM           698,103 sqlite-analyzer-win32-x86-3080500.zip
>140703  03:40 PM           533,745 sqlite-dll-win64-x64-3080500.zip
>140709  11:18 AM         4,446,454 sqlite-doc-3080500.zip
>140703  03:41 PM           301,951 sqlite-shell-win32-x86-3080500.zip
>140703  03:41 PM             5,452 sqlite370_banner.gif
>               5 File(s)      5,985,705 bytes
>               0 Dir(s)  27,665,055,744 bytes free
>
>
>
>
>these files, 
>
>
>and ended up making a directory C:\sqlite on my c drive like so:
>
>
> Directory of C:\sqlite
>
>
>140710  02:43 PM    <DIR>          .
>140710  02:43 PM    <DIR>          ..
>140710  02:43 PM            91,786 a.exe
>140710  02:39 PM           162,722 libsqlite3.a
>140710  02:38 PM                56 session.txt
>140604  09:21 PM           124,070 shell.c
>140710  02:01 PM    <DIR>          sqlite-amalgamation-3080500
>140710  01:40 PM    <DIR>          sqlite-doc-3080500
>140604  09:21 PM         5,239,373 sqlite3.c
>140630  12:19 PM             4,721 sqlite3.def
>140630  12:19 PM         1,238,016 sqlite3.dll
>140604  09:22 PM           547,840 sqlite3.exe
>140604  09:21 PM           360,297 sqlite3.h
>140604  09:21 PM            26,110 sqlite3ext.h
>140710  02:40 PM               682 t.lis
>140710  02:42 PM               885 test.c
>              12 File(s)      7,796,558 bytes
>               4 Dir(s)  27,661,144,064 bytes free
>
>
>
>
>following the instructions here: 
>http://www.tutorialspoint.com/sqlite/sqlite_installation.htm
>
> 
>and then the sample project here: 
>http://www.tutorialspoint.com/sqlite/sqlite_c_cpp.htm
>
> 
>well I had all kinds of trouble getting through the linker, spend hours 
>searching the web and finally found the command:
>
>
>dlltool -D sqlite3.dll -d sqlite3.def -l libsqlite3.a
>
>
>
>which seemed to make the library I needed which seems to be some big secret. 
>
>
>anyway here is the test.c program I tried to run: 
>
>
>
>
>
>
>
>
>//bof
>#include <stdio.h>
>#include "sqlite3.h" 
>
>
>/************************************************************\
>Now, let's compile and run above program to create our database 
>test.db in the current directory. You can change your path as 
>per your requirement.
>
>
>$gcc test.c -l sqlite3
>$./a.out
>Opened database successfully
>
>
>
>
>
>
>doskey
>\jon\bat\local
>dlltool -D sqlite3.dll -d sqlite3.def -l libsqlite3.a
>gcc test.c -L/sqlite -l sqlite3
>doskey/history
>
>
>\************************************************************/
>
>
>
>
>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);
>} //main
>//eof
>
>
>
>
>Now, when I run a.exe, it crashes with an "application was unable to start 
>correctly (0xc000007b)" error. 
>
>
>question 1) what am I doing wrong?
>
>
>so I keep searching the web and I find:
>
>
>http://www.sqlite.org/quickstart.html
>
> 
>and they show this really nice program:
>01  #include <stdio.h>
02  #include <sqlite3.h>
03  
04  static int callback(void *NotUsed, int argc, char **argv, char **azColName){
05    int i;
06    for(i=0; i<argc; i++){
07      printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
08    }
09    printf("\n");
10    return 0;
11  }
12  
13  int main(int argc, char **argv){
14 sqlite3 *db;
15    char *zErrMsg = 0;
16    int rc;
17  
18    if( argc!=3 ){
19      fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
20      return(1);
21    }
22    rc = sqlite3_open(argv[1], &db);
23    if( rc ){
24      fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
25 sqlite3_close(db);
26      return(1);
27    }
28    rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
29    if( rc!=SQLITE_OK ){
30      fprintf(stderr, "SQL error: %s\n", zErrMsg);
31 sqlite3_free(zErrMsg);
32    }
33 sqlite3_close(db);
34    return 0;
35  }
>
>
>but don't follow through with how to compile and link it.
>
>
>I tried:
>C:\sqlite>gcc test02.c -otest02.exe -L/sqlite -l sqlite3
test02.c:2:23: fatal error: sqlite3.h: No such file or directory #include 
<sqlite3.h> ^
compilation terminated. C:\sqlite>winelvis test02.c C:\sqlite>gcc test02.c 
-otest02.exe -L/sqlite -l sqlite3 C:\sqlite>test02 C:\sqlite>
>
>
>
>but it crashed just like a.exe. 
>question 2) any help on getting this program to run?
>
>
>TIA, 
>
>
>Jon
>
>
>
>
>
>
>
>
>
>
>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to