0

So I'm trying to use the Sqlite API in a Eclipse C++ project. I've tried adding the -L, and -lsqlite to the compilation option. The error I'm getting is that sqlite3.h does not exist. Here's the source for my main.cpp file. Thoughts?

#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <string.h>
#include "Sequence/DnaSequenceParser.h"
#include "Sequence/Genome.h"
#include "SequenceComparision/DifferenceVector.h"
#include "SequenceComparision/Difference.h"
#include "Sequence/GenomeRepository.h"
#include "SequenceComparision/DifferenceVectorMatrix.h"
#include "Analysis/DifferenceMatrixAnalyzer.h"
#include <sqlite3.h>

using namespace std;

GenomeRepository repo;

static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
string id, seq;

for(i=0; i<argc; i++){
    if (strcmp(azColName[i], "gba") == 0) {
        id = argv[i];
    }
    else if (strcmp(azColName[i], "aligned") == 0) {
        seq = argv[i];
    }
  // printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
repo.Add(id, seq);

// printf("\n");
return 0;
}

int main() {

repo = GenomeRepository();
string id, seq;

sqlite3 *db;
char *zErrMsg = 0;
int rc;

rc = sqlite3_open("genome.db", &db);
if( rc ){
  fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
  sqlite3_close(db);
  return(1);
}
rc = sqlite3_exec(db, "select * from genome;", callback, 0, &zErrMsg);
// rc = sqlite3_exec(db, "select * from genome where gba='KP120616';", callback, 0, &zErrMsg);
if( rc!=SQLITE_OK ){
  fprintf(stderr, "SQL error: %s\n", zErrMsg);
  sqlite3_free(zErrMsg);
}
sqlite3_close(db);


//string firstSequence ="AAAACCCCTTTA";
//string secondSequence ="AAAAACCCTTTT";
//string thirdSequence ="AATAACCCTTCT";
//string IdA = "a";
//string IdB = "b";
//string IdC = "c";
//repo.Add(IdA, firstSequence);
//repo.Add(IdB, secondSequence);
//repo.Add(IdC, thirdSequence);
DifferenceVectorMatrix matrix = DifferenceVectorMatrix(repo);
// cout << matrix.Get(1,0).ToString();
// cout << matrix.Get(1,0).ToString();

DifferenceMatrixAnalyzer a = DifferenceMatrixAnalyzer(matrix);
printf("Average number of differences: %f\n", a.AverageNumberOfDifferences());
printf("Standard Deviation: %f\n",a.StdDeviationNumberOfDifferences());

}

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190

0 Answers0