Your program should look more like this -
sqlite *db;
char *errmsg = NULL; /*Ptr to possible error message.*/
int main() {
printf("Hello!\n");
db = sqlite_open("sqlitetest", 0660, &errmsg);
/*At this point if you get an error errmsg will not be null
and will point to the error message. It will have malloc'd
memory for that message so you need to "free" it or suffer
a memory leak.*/
if (errmsg != NUL) {
...
}
.....
}
I guess you are new to C. It will get easier. The first ten years are
the hardest.
Keiichi McGuire wrote:
Hi John,
I still get an error when i use the -lsqlite switch. When i take that
out it
says:
incompatible types in assignment
passing arg 3 of 'sqlite_open' from incompatible pointer type
also I wanted to use v.3, but i'm working on a system where the disk space
is limited to 64megs, and i actually got the v2 from an ipkg package, and
there was an sqlite3 package available, but it was not compatible with php
that is on this system.
-Keiichi
On 7/11/06, John Stanton <[EMAIL PROTECTED]> wrote:
Keiichi McGuire wrote:
> Hi everyone,
> I'm still a bit new to sqlite and also to crosscompiling programs.
> I've been having problems with being able to compile this test c
program
> that should just connect to the database.
>
> My program looks like this:
>
> #include<stdio.h>
> #include"sqlite.h>
>
> int main()
> {
>
> printf("Hello!\n");
> sqlite *db;
> char errMsg;
> errMsg = NULL;
>
> db = sqlite_open("sqlitetest",0660,&errMsg);
>
> return 0;
> }
>
>
> and I get the following error:
>
> [EMAIL PROTECTED] dev]# arm-linux-gcc test.c -o test4 -L
> /home/kmcgui/sqlite-arm/.lib
>
> s/ -lsqlite tesc: In function `main':
> test.c:9: warning: assignment makes integer from pointer without a cast
> test.c:11: warning: pabssing arg 3 of qlite_open' from incompatible
pointer
> type
>
/usr/local/arm/3.3.2/lib/gcc-lib/arm-linux/3l.3.2/../../../.m-linux/biin/ld:
>
> skipping mpatible /home/kmcgui/sqlite-arm/.flibs//libsqliteso when
> senarching for
>
-ls/local/armi/3.3.2/lib/gcc-e/usr/local/arm/3.3.2/lib/gcc-lib/arm-linux/3.3.2/../../../../arm-linux/bin/ld:
>
> skipping incompatible
> /usr/local/arm/3.3.2/lib/gcc-lib/arm-linux/3.3.2/libsqlite.a when
> searlching
> for -lsqle
>
/usr/local/arm/3.3.2/lib/gcc-lib/arm-linux/3.3.2/../../../../arm-linux/bin/ld:
>
> cannot find -lsqlite
> collect2: ld rxeturned 1 exit s
>
> thank you in advance!!!
>
>
> -Keiichi
>
Try declaring errMsg as a character array rather than a character,
char errMsg[256];
Arg3 3 of sqlite_open is of type char **.
Note that you are using Sqlite V2. If you are starting a new project
you might find using Sqlite V3 from the beginning a good idea.