Integrate SQLite3 w/TGE_1.5.1 on Mac
by Corey Punches · 05/15/2007 (8:54 am) · 2 comments
Download Code File
This resource is an extension of the great work of John Vanderbeck, and Dreamer. You'll need to read through their resource write-ups to get an idea of how this works.
You can find John's original resource here: John's Resource
You can find Dreamer's resource here:
Dreamer's Resource
Ok, so here's what I've added. In the atttached file you will find an updated SQLObject.h, and updated SQLObject.cc. I've also included an updated sqlite.cs file for testing and example purposes.
Sqlite is included with OSX, and is a part of the Cocoa data framework so there isn't any need to download and build sqlite from sqlite.org (unless you need a more recent version - OSX 10.4 ships with 3.1.3). To ensure you have it installed on your Mac open a terminal and execute sqlite3 at the prompt, the sqlite command interpreter should startup and display a version message. Enter .quit at the sqlite prompt and press enter to exit. If for some reason you determine that sqlite3 is not installed you have a couple of choices. Download from sqlite.org, or use darwinports to download and install (I recommend the darwinports method just because it's easier).
To add sqlite support to TGE open your project in Xcode. Add SQLObject.h and SQLObject.cc to your project - I created a new folder and added the files there, or you can just drop them into the console folder. You will need to add libsqlite3.a (or libsqlite3.dylib, but I wanted to static link) to your project as well, mine was located at: /opt/local/lib/libsqlite3.a (I used darwinports to get my version of sqlite3 before I discovered it was already installed ;)). Check your project settings to ensure that the library path is in the library search path.
You should be able to successfully build the project now.
Drop the sqlite.cs file into your client/scripts folder and don't forget to exec it in your init.cs
Now fire up your executable (I use the starter.fps mod for testing) and press the ~ to show the console.
enter
You should see some messages about a test character being created. If you don't something went horribly wrong and your computer is liable to explode! ;) Just kidding of course, hopefully you'll see a nice error message that will help you narrow down the problem.
The example script gives you examples of various sql commands such as creating tables, inserting data, and retrieving data from tables.
That's it, hopefully this will help some of the other folks developing on Mac's add a persistence layer to their projects.
A big thanks to John and Dreamer - they did all the hard work.
This resource is an extension of the great work of John Vanderbeck, and Dreamer. You'll need to read through their resource write-ups to get an idea of how this works.
You can find John's original resource here: John's Resource
You can find Dreamer's resource here:
Dreamer's Resource
Ok, so here's what I've added. In the atttached file you will find an updated SQLObject.h, and updated SQLObject.cc. I've also included an updated sqlite.cs file for testing and example purposes.
Sqlite is included with OSX, and is a part of the Cocoa data framework so there isn't any need to download and build sqlite from sqlite.org (unless you need a more recent version - OSX 10.4 ships with 3.1.3). To ensure you have it installed on your Mac open a terminal and execute sqlite3 at the prompt, the sqlite command interpreter should startup and display a version message. Enter .quit at the sqlite prompt and press enter to exit. If for some reason you determine that sqlite3 is not installed you have a couple of choices. Download from sqlite.org, or use darwinports to download and install (I recommend the darwinports method just because it's easier).
To add sqlite support to TGE open your project in Xcode. Add SQLObject.h and SQLObject.cc to your project - I created a new folder and added the files there, or you can just drop them into the console folder. You will need to add libsqlite3.a (or libsqlite3.dylib, but I wanted to static link) to your project as well, mine was located at: /opt/local/lib/libsqlite3.a (I used darwinports to get my version of sqlite3 before I discovered it was already installed ;)). Check your project settings to ensure that the library path is in the library search path.
You should be able to successfully build the project now.
Drop the sqlite.cs file into your client/scripts folder and don't forget to exec it in your init.cs
exec("./scripts/sqlite.cs");Now fire up your executable (I use the starter.fps mod for testing) and press the ~ to show the console.
enter
sqliteCreateTestDatabase(test, testguy);
You should see some messages about a test character being created. If you don't something went horribly wrong and your computer is liable to explode! ;) Just kidding of course, hopefully you'll see a nice error message that will help you narrow down the problem.
The example script gives you examples of various sql commands such as creating tables, inserting data, and retrieving data from tables.
That's it, hopefully this will help some of the other folks developing on Mac's add a persistence layer to their projects.
A big thanks to John and Dreamer - they did all the hard work.
About the author
#2
11/21/2008 (8:48 am)
Hey Corey! Pretend I'm a mac and xcode noobie... where does libsqlite3.a come from? It's not in the folder you have. 
Torque Owner Garth Johnson