LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   undefined reference to `sqlite3_open' (https://www.linuxquestions.org/questions/linux-newbie-8/undefined-reference-to-%60sqlite3_open-812687/)

miamagoo 06-07-2010 11:45 AM

undefined reference to `sqlite3_open'
 
Hello,

I am a Linux newbie, SQLite3 newbie and C++ newbie.

I have a little C++ program that I am attempting to connect to a test database.

#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;
}
}

When I compile this code, I get the error: undefined reference to `sqlite3_open'

I added sqlite3 package using the command 'apt-get install sqlite3'. Unfortunately the sqlite3.h header file was not installed in /usr/include, so I downloaded the SQLite3 dist., untarred it and copied the sqlite3.h file to /usr/include.

I saw on a previous message that I would need to link the library. The only library file in /usr/lib is libsqlite3.so.0, so the command g++ -lsqlite3 still gives me an error.

Any help is appreciated. I am stabbing in the dark here.

AlucardZero 06-07-2010 12:00 PM

apt-get install libsqlite3-dev ?

Also, it would be nice if you told us what Linux distro you are using.

miamagoo 06-07-2010 12:48 PM

Distro
 
Quote:

Originally Posted by AlucardZero (Post 3995568)
apt-get install libsqlite3-dev ?

Also, it would be nice if you told us what Linux distro you are using.

I am using Ubuntu

AlucardZero 06-07-2010 12:50 PM

Did it solve your problem?

miamagoo 06-08-2010 06:44 AM

problem solved
 
Yes, thank you! It worked like a charm! I will probably be submitting more questions as I go - you guys are great!

Kofgarter 06-15-2010 09:49 AM

I wonder, is it possible to use sqlite in the same way, but without installing in system, just by including required libs.
if it's possible, then how to do it?
Thanks.

Radha@adl 10-17-2022 02:11 AM

can u Help me out iam also having same issue
 
Quote:

Originally Posted by miamagoo (Post 3996509)
Yes, thank you! It worked like a charm! I will probably be submitting more questions as I go - you guys are great!

CAn u help me out how did this get solved????

pan64 10-17-2022 02:35 AM

Quote:

Originally Posted by Radha@adl (Post 6386796)
CAn u help me out how did this get solved????

Yes, you only need to read the thread (post #2). Otherwise please do not reopen a 12 years old thread.


All times are GMT -5. The time now is 01:18 AM.