Error: undefined reference to `sqlite3_open'

前端 未结 4 2007
孤独总比滥情好
孤独总比滥情好 2020-12-13 18:28

I\'m trying to get started with the C++ API for SQLite.

#include 
#include 

using namespace std;

int main()
{
    sqlite3         


        
相关标签:
4条回答
  • 2020-12-13 18:50

    First step: Install all library sqlite3 with the command:

            sudo apt-get install libsqlite3-dev
    

    With that you can use #include <sqlite3.h> in a programm of C or C++.

    Second step: To compile the program by console:

    C++:

            g++ program.cpp -o executable -lsqlite3
    
            ./executable
    

    C:

            gcc program.c -o executable -lsqlite3
    
            ./executable
    
    0 讨论(0)
  • 2020-12-13 18:58

    You need to link the sqlite3 library along with your program:

    g++ main.cpp -lsqlite3
    
    0 讨论(0)
  • 2020-12-13 19:08

    You need to adjust your linker flags to link in the sqlite3 library. Libraries are usually installed in /usr/lib or /usr/lib64

    Alternatively, you can copy the sqlite3.c file to your project directory and compile it as part of the g++ command:

    g++ main.cpp sqlite3.c 
    

    as per: http://sqlite.org/cvstrac/wiki?p=HowToCompile

    0 讨论(0)
  • 2020-12-13 19:13

    Either link your program to lib g++ yourProgram.c -lsqlite3 in command line or in Open IDE -> project -> properties -> locate lib file for sqlite3 .

    0 讨论(0)
提交回复
热议问题