Pages: [1]   Go Down
Send this topic | Print
Author Topic: SQLite and C++?  (Read 1861 times)
aldo
Official 110mb Guru
********
Offline Offline

Posts: 8004


SMF is ftw :D


WWW
« on: September 11, 2008, 09:32:50 AM »

I have lately been interested in integrating SQLite with something like C++

Now first I was wondering, is this even possible? If so, does anyone have a tutorial they know of that shows you how you do it?

Another thing, I have also been messing with the command-line program for accessing and modifing SQLite databases, however, I don't get how I make a new database and everything.

I look at the Docs for it (http://sqlite.org/sqlite.html) but I type sqlite3 ex1; into the command-line, and I get SQL Error: near "sqlite3", and I don't see anywhere else to type that to make a new database =|
Logged


inp o҉rtb
The Gangsta
Global Moderator
Official 110mb Guru
*****
Offline Offline

Posts: 15633


experimental theologian


WWW
« Reply #1 on: September 11, 2008, 10:06:58 AM »

Absolutely; just link your program against SQLite? http://www.sqlite.org/capi3.html

I've never tried the "official" C++ interface, but when I worked with SQLite/C++, I had to wrap the C interface into my own C++ classes (there was no C++ wrapper at the time, and it looks like there's no C++ interface now as well). Then again, there's nothing wrong with just using the C functions straight in C++.

Duh
Logged

Hi! I’m a signature virus! Add me to your signature to help me spread.
spam me: ispamspot@gmail.com

blog | my work @ deviantART | Imagine-ng image editor
aldo
Official 110mb Guru
********
Offline Offline

Posts: 8004


SMF is ftw :D


WWW
« Reply #2 on: September 11, 2008, 10:24:56 AM »

How do I link it? The thing is, these things never make sense. When I make tutorials, I just say how you do it, and show an example code, lol...
Logged


inp o҉rtb
The Gangsta
Global Moderator
Official 110mb Guru
*****
Offline Offline

Posts: 15633


experimental theologian


WWW
« Reply #3 on: September 11, 2008, 10:52:51 AM »

Well... the GCC/G++ process is pretty straightforward. First it compiles C/C++ to assembly language, then it assembles the assembly source into object code, and finally it links object code into executables or libraries. Basically, when you link, tell the linker to add the SQLite library. (of course, you also have to #include the SQLite headers during compilation).

If you run GCC/C++ in a single command, I believe you specify libraries that you want to link against using the -L parameter, and include files using the -I parameter.
Logged

Hi! I’m a signature virus! Add me to your signature to help me spread.
spam me: ispamspot@gmail.com

blog | my work @ deviantART | Imagine-ng image editor
aldo
Official 110mb Guru
********
Offline Offline

Posts: 8004


SMF is ftw :D


WWW
« Reply #4 on: September 11, 2008, 10:55:49 AM »

The SQLite Library is the dll right? huh
Logged


inp o҉rtb
The Gangsta
Global Moderator
Official 110mb Guru
*****
Offline Offline

Posts: 15633


experimental theologian


WWW
« Reply #5 on: September 11, 2008, 10:58:53 AM »

Oh, then that's a bit different, if you're using a shared library instead of a static library.

Actually, the shared library should still come with a tiny static library stub, which you link your application against. The stub is basically a redirector that calls functions in the shared library. Of course, you don't have to use the static stub, but then you'd have to dig into the Win32 API for LoadLibrary() and so on.

(While I've done that before, you really should not be asking me for details on the Win32 API. Check the MSDN for more information ;p )
Logged

Hi! I’m a signature virus! Add me to your signature to help me spread.
spam me: ispamspot@gmail.com

blog | my work @ deviantART | Imagine-ng image editor
aldo
Official 110mb Guru
********
Offline Offline

Posts: 8004


SMF is ftw :D


WWW
« Reply #6 on: September 11, 2008, 11:05:54 AM »

Ok, *goes to Google*
Logged


inp o҉rtb
The Gangsta
Global Moderator
Official 110mb Guru
*****
Offline Offline

Posts: 15633


experimental theologian


WWW
« Reply #7 on: September 11, 2008, 11:11:01 AM »

btw, have you checked out gamedev.net? It's an awesome community of developers and you might find some SQLite-integration tutorials there (I think I learned about the SQLite/C interface there).

http://www.gamedev.net/reference/
Logged

Hi! I’m a signature virus! Add me to your signature to help me spread.
spam me: ispamspot@gmail.com

blog | my work @ deviantART | Imagine-ng image editor
Primefalcon
Linux Acolyte
Loyal 110MB Member
*******
Online Online

Posts: 4640


Follow the path of Linux, it will lead you....


« Reply #8 on: September 11, 2008, 11:20:39 AM »

yes gamedev is great a great resource
Logged

Dropbox is an amazing cloud storage backup solution, get a free 2.25 gigabytes of storage by using THIS LINK

For Tips on Runescape, Visit Marlaine's Musings For Tips on Just about anything Visit Marlainemarie at eHow
Pages: [1]   Go Up
Send this topic | Print
Jump to: