Monday, December 22, 2008

Getting A Boost

Tonight I set a task to grab Boost. I just wanted the libraries, not the source. So, I proceeded over to www.finkproject.org. Fink provides a free tool that allows you to grab packages and install to your Mac. Since, I'm still a Mac virgin I needed a simple tool, because I wasn't about to attempt to download, install, and build Boost...sheesh, this job turned out to be frustrating enough.

1) First I downloaded the Fink installer package from www.finkproject.org.
2) Double clicked on the install package that was downloaded. (this installed perfectly, and the Fink Installer appended the directory where it installed to /sw into my environment path).

Next to grab Boost...Fink has its own packaging mechanism, so you have to grab the packages from their site. Unfortunately, they haven't updated to Boost-1_37, so you have to make do with Boost-1_33.  (Here's where my frustration began) The files are protected so you have to run "sudo," to get prompted to enter your username and password.  This is your username/password of your Mac.  I haven't touched any flavors of Unix in 15 years, so I had to hunt to find how to give myself permission.  Searching the net I came across "sudo." So...

3) sudo fink install boost1.33-shlibs  (that is what you have to type...oh yeah, grab the terminal window from your /applications/utility folder. I moved it to my desktop for keeps).

After that grabs packages from the Fink site, type...

4) fink install boost1.33 (boost is now installed to /sw/include/boost-1_33_1

Thus, I went to XCode to include one of my Boost favorites, smart_ptr.h.  So, I type in #include "boost/smart_ptr.h" and compile, no need setting up code if I can't compile so that is all I added, and built.  Sheesh!  A compile error, smart_ptr.h could not be found.  Okay, how do I set an environment path on the Mac, after hunting for about an hour, I found a way that actually append the directory to the $PATH, ( echo 'export PATH=YOURPATHHERE:$PATH' >> ~/.profile, replacing "YOURPATHHERE") but that still didn't fix the XCode compile problem.

So, I found the Project Settings in XCode, goto Project, Edit Project Settings, Header Search Paths.  Double click that and hit the '+' button to enter the path where Fink installed Boost, "/sw/include/boost-1_33_1".

So, now I'm ready.  Damn it!  Still a compile error.  So, I went to the Boost folder (oh this is a peeve of mine with the Mac, the folders never give you the full paths of where you are...if someone knows if it is an option that needs to be set so that it appears on the folder, please shoot me a comment) to see if I had the path correct.  I did however, the file isn't "smart_ptr.h," on the Mac it is "smart_ptr.hpp."  So, with that change, I got my Boost.

Also, I kicked off "Time Machine," to backup my machine.  I backed up and burned all my Final Cut Pro stuff that was on my external HD to DVD, to make room.  The drive is 150 GB, the backup of my whole Mac is 87.78 GB.  The first time you run "Time Machine," it backs everything up, after that it only backs up whatever has changed.  So, I kicked that off around 8:15pm, the time is now 11:33pm and it has only copied over 44.64 GB.  So, it copied about half the machine in three hours, so I guess it has another three to go.

Well, I'm going to go do some more bridge testing, because I want to see what happens if a class has virtual functions.  I know that an Obj-C class cannot instantiate a C++ class (or its superclasses) that has virtual member functions defined.  

I want to find out if a C++ class inside an Obj-C class interface, can instantiate another class that has virtual member functions, because what I am trying to see if I can do is the following in iPhone code (the following code example is a snippet of what is found in the Delegate class in iPhone dev)...




- (void) RunGame
{
// lets assume StairwayToHeaven class is defined and apart of
// the Delegate class and has been instantiated
pStairwayToHeaven->RunGame(); // this would handle everything needed and all be in C++/Lua
}

/* That's where we initialize the game objects */
- (void) applicationDidFinishLaunching:(UIApplication*)application
{
CGRect rect = [[UIScreen mainScreen] bounds];
NSAutoreleasePool* pool = [NSAutoreleasePool new];
.
.
.

//Initializing game timer
_timer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / kFPS) target:self selector:@selector(RunGame) userInfo:nil repeats:YES];

.
.
.
}

That is what I'm trying to do...have one interface out of Obj-C to C++/Lua heaven. I don't know if it is possible, but I intend to find out.

No comments: