Search code examples
c++ceclipsesqliteeclipse-cdt

How to use sqlite3.c and sqlite3.h in eclipse C/C++ project


I am trying to use amalgamated version of sqlite3.c and sqlite3.h in my C/C++ project. It has code in both C and C++. I am using eclipse IDE in UBUNTU 12.04.

Now my problem is that after having include sqlite3.h in my file where I need sqlite3.c functions and having added ld and pthread libraries in linker, i am still getting errors and cant build the project.

This is weird and should not happen. Please take a look at following screenshots that explain my problem.

Snapshot of project

************************************************************************************

Errors Snapshot

************************************************************************************

Snapshot of included libs

What am I missing?

Please Help! Thanks


Solution

  • Make sure that the pthread library is linked before the dl library.

    In other words, your compiler command (as generated by Eclipse) should be:

    gcc shell.c sqlite3.c -lpthread -ldl

    and not

    gcc shell.c sqlite3.c -ldl -lpthread

    See here for a correct command line:

    http://www.sqlite.org/howtocompile.html