Gary G Allen wrote:
Hello Everyone in SQLite land.
I am totally new to the sites and sounds here.
I have a issue. I hope you can help me with.
I downloaded source code from:
http://www.sqlite.org/download.html
sqlite-3_4_2.zip
(179.14 KB)
Ran the makefile and everything worked fine.
I have been trying to run the code at:
http://www.sqlite.org/quickstart.html
SQLite in 5 minutes.
The source code I am trying to compile is below.
%:gcc -o sqlite_test sqlite_test.c
I am getting the compile error:
undefined reference on -
sqlite3_open(argv[1], &db);
sqlite3_close(db);
sqlite3_errmsg(db)
sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
Can Anyone Help Me Out?
Regards,
Gary
-------------
#include <stdio.h>
#include <sqlite3.h>
static int callback(void *NotUsed, int argc, char **argv, char
**azColName){
int i;
for(i=0; i<argc; i++){
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
}
int main(int argc, char **argv){
sqlite3 *db;
char *zErrMsg = 0;
int rc;
if( argc!=3 ){
fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
exit(1);
}
rc = sqlite3_open(argv[1], &db);
if( rc ){
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
if( rc!=SQLITE_OK ){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
sqlite3_close(db);
return 0;
}
You haven't defined the link library. If you installed Sqlite just add
-lsqlite3 to your compile command.
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------