[Linuxtrent] Errore linkinh libsqlite3

  • From: Mario Alexandro Santini <alexmario74@xxxxxxxxx>
  • To: linuxtrent@xxxxxxxxxxxxx
  • Date: Sun, 6 Nov 2011 11:49:33 +0100

Ciao a tutti,
mi trovo ad affrontare un piccolo rompicapo di compilazione c e c++.

In breve, sto cercando di compilare un esempio di codice c++ con le
librerie sqlite3 su una Ubuntu 11.10.

Ho installato le librerie:

libsqlite3-0 libsqlite3-dev libsqlite3-0-dbg

Quindi ho preso un esempio in C++ da compilare:

textSQLite.cpp
---------------------------------------------------------------------
#include <iostream>
using namespace std;

#include <sqlite3.h>


int main ()
{

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

    rc = sqlite3_open( "DBm", & db);
    if (rc)
    {
    cout << "faileure to open database ";
    cout << endl;
    }
}
---------------------------------------------------------------------

Poi provo a compilare:

$ g++ -lsqlite3 textSQLite.cpp

e ottengo:

/tmp/cccEysg3.o: In function `main':
textSQLite.cpp:(.text+0x21): undefined reference to `sqlite3_open'
collect2: ld returned 1 exit status

$ g++ --version
g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Da un giro su google non ho trovato suggerimenti in proposito.
Qualcuno di voi può darmi qualche dritta?

Grazie.

PS Bella cosa le domeniche piovose...

-- 
Ciao,
      Mario

Other related posts: