LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-07-2010, 12:45 PM   #1
miamagoo
Member
 
Registered: Jun 2010
Posts: 32

Rep: Reputation: 15
Question 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.
 
Old 06-07-2010, 01:00 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,808

Rep: Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604
apt-get install libsqlite3-dev ?

Also, it would be nice if you told us what Linux distro you are using.
 
1 members found this post helpful.
Old 06-07-2010, 01:48 PM   #3
miamagoo
Member
 
Registered: Jun 2010
Posts: 32

Original Poster
Rep: Reputation: 15
Distro

Quote:
Originally Posted by AlucardZero View Post
apt-get install libsqlite3-dev ?

Also, it would be nice if you told us what Linux distro you are using.
I am using Ubuntu
 
Old 06-07-2010, 01:50 PM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,808

Rep: Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604
Did it solve your problem?
 
Old 06-08-2010, 07:44 AM   #5
miamagoo
Member
 
Registered: Jun 2010
Posts: 32

Original Poster
Rep: Reputation: 15
problem solved

Yes, thank you! It worked like a charm! I will probably be submitting more questions as I go - you guys are great!
 
Old 06-15-2010, 10:49 AM   #6
Kofgarter
LQ Newbie
 
Registered: Jun 2010
Posts: 1

Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SQLite3, C++ & Ubuntu - undefined reference to `sqlite3_open' miamagoo Ubuntu 1 06-07-2010 03:25 PM
undefined reference to.... crapodino Programming 1 01-13-2008 08:05 PM
undefined reference to... dimah Programming 3 12-27-2006 10:57 AM
undefined reference vkmgeek Programming 1 05-11-2006 07:37 AM
Undefined Reference ChemicalBurn Programming 2 02-14-2005 04:01 AM


All times are GMT -5. The time now is 05:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration