New to SQLite. Copied a program from a tutorial site to test whether it is working or not!
compiled using following commandCode:#include <iostream> #include <sqlite3.h> #include <stdlib.h> // g++ AccessTableEmployee.cpp -lsqlite3 using namespace std; static int callback(void *NotUsed, int argc, char **argv, char **azColName) { int i; cout << "Number of args= " << argc << endl; for(i=0; i<argc; i++) { cout << azColName[i] << " = " << (argv[i] ? argv[i] : "NULL") << endl; } cout << endl; return 0; } int main(int argc, char **argv) { sqlite3 *db; // Declare pointer to sqlite database structure char *zErrMsg = 0; // Open Database int rc = sqlite3_open("Try.db", &db); if( rc ) { cerr << "Can't open database: " << sqlite3_errmsg(db) << endl; sqlite3_close(db); exit(1); } // Select from database rc = sqlite3_exec(db,"select * from emp", callback, 0, &zErrMsg); if( rc!=SQLITE_OK ) { cerr << "SQL error: " << zErrMsg << endl; sqlite3_free(zErrMsg); } // Close sqlite3_close(db); return 0; }
g++ -o SQL SQLite.cpp
I am getting following error
/tmp/ccxSqt2x.o: In function `main':
SQLTry.cpp: (.text+0xfd): undefined reference to `sqlite3_open'
SQLTry.cpp: (.text+0x114): undefined reference to `sqlite3_errmsg'
SQLTry.cpp: (.text+0x152): undefined reference to `sqlite3_close'
SQLTry.cpp: (.text+0x18a): undefined reference to `sqlite3_exec'
SQLTry.cpp: (.text+0x1d5): undefined reference to `sqlite3_free'
SQLTry.cpp: (.text+0x1e1): undefined reference to `sqlite3_close'
collect2: ld returned 1 exit status
googled for the solution and came across the same solution every where in the from of following command
g++ -o SQL -lsqlite3 SQLite.cpp
But this solution is not working with me!
Any Help Appreciated!
Using GCC on Debian Linux...



LinkBack URL
About LinkBacks



