<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Paul Solt &#187; C++</title>
	<atom:link href="http://paulsolt.com/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://paulsolt.com</link>
	<description>Putting the Inc back in Solt since 2005.</description>
	<lastBuildDate>Fri, 03 Feb 2012 05:04:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>clang++ is awesome, goodbye g++</title>
		<link>http://paulsolt.com/2011/09/clang-is-awesome-goodbye-g/</link>
		<comments>http://paulsolt.com/2011/09/clang-is-awesome-goodbye-g/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 22:26:43 +0000</pubDate>
		<dc:creator>Paul Solt</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[clang++]]></category>
		<category><![CDATA[compilers]]></category>
		<category><![CDATA[g++]]></category>

		<guid isPermaLink="false">http://paulsolt.com/?p=1188</guid>
		<description><![CDATA[<p>I finally got around to reading up on the clang compiler and I love it. The error messages are so helpful. Here&#8217;s a quick example with a syntax error. Lets compile it on the command line.</p> #include &#60;iostream&#62; int main() { std::cotut &#60;&#60; "Hello World"; return 0; } <p><br /> What happens when I run [...]]]></description>
			<content:encoded><![CDATA[<p>I finally got around to reading up on the clang compiler and I love it. The error messages are so helpful. Here&#8217;s a quick example with a syntax error. Lets compile it on the command line.</p>
<pre style="padding-left: 30px;">#include &lt;iostream&gt;
int main() {
	std::cotut &lt;&lt; "Hello World";
	return 0;
}</pre>
<p><span id="more-1188"></span><br />
What happens when I run the code with g++?</p>
<pre style="padding-left: 30px;">paulsolt@~/dev $ g++ test.cpp
test.cpp: In function ‘int main()’:
test.cpp:3: error: ‘cotut’ is not a member of ‘std’</pre>
<pre style="padding-left: 30px;"></pre>
<p>Here&#8217;s what happens in clang++, notice how it highlights the position and it&#8217;s actually more helpful in fixing the error.</p>
<pre style="padding-left: 30px;">paulsolt@~/dev $ clang++ test.cpp
test.cpp:4:7: error: no member named 'cotut' in namespace 'std'; did you mean 'cout'?
        std::cotut &lt;&lt; "Hello World";
        ~~~~~^~~~~
             cout
/usr/include/c++/4.2.1/iostream:63:18: note: 'cout' declared here
  extern ostream cout;          ///&lt; Linked to standard output</pre>
]]></content:encoded>
			<wfw:commentRss>http://paulsolt.com/2011/09/clang-is-awesome-goodbye-g/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Objective-C/C++ iPhone Build Failures</title>
		<link>http://paulsolt.com/2010/11/objective-cc-iphone-build-failures/</link>
		<comments>http://paulsolt.com/2010/11/objective-cc-iphone-build-failures/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 03:38:31 +0000</pubDate>
		<dc:creator>Paul Solt</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[build errors]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[GCC]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://paulsolt.com/?p=994</guid>
		<description><![CDATA[<p>If you&#8217;re working with Objective-C/C++ (i.e. mixing both languages) in an iPhone/Mac application you may come across some strange errors in the build process due to a configuration issue.</p> error: bits/c++config.h: No such file or directory <p>One of my projects, Texture Evolution was a Mac application that referenced a C++ Mac library. About 6 months [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re working with Objective-C/C++ (i.e. mixing both languages) in an iPhone/Mac application you may come across some strange errors in the build process due to a configuration issue.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">error: bits<span style="color: #000000; font-weight: bold;">/</span>c++config.h: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory</pre></div></div>

<div id="attachment_1005" class="wp-caption aligncenter" style="width: 467px"><a href="http://paulsolt.com/wp-content/uploads/2010/11/buildFailBits.png"><img class="size-full wp-image-1005 " title="buildFailBits" src="http://paulsolt.com/wp-content/uploads/2010/11/buildFailBits.png" alt="" width="457" height="560" /></a><p class="wp-caption-text">Too many build failures</p></div>
<p>One of my projects, Texture Evolution was a Mac application that referenced a C++ Mac library. About 6 months ago I ran into an issue where my build would fail. It may have been related to an update to Xcode, but I&#8217;m not entirely sure. After a lot of time, frustration, Google&#8217;ing, and project configuration changes I came across a solution.</p>
<p>Today I ran into the same problem and couldn&#8217;t quite remember how to fix it for my Doxygen Xcode documentation Target that references the C++ Mac library. I wasted more time trying to figure it out again, so here&#8217;s the breakdown.</p>
<h3>The Problem:</h3>
<p>Using iostream.h or other STL from C++ and compiling with the Base SDK set to 10.4 and GCC 4.0.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>SDKs<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS4.1.sdk<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>c++<span style="color: #000000; font-weight: bold;">/</span>4.0.0<span style="color: #000000; font-weight: bold;">/</span>iostream:<span style="color: #000000;">43</span>:<span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>SDKs<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS4.1.sdk<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>c++<span style="color: #000000; font-weight: bold;">/</span>4.0.0<span style="color: #000000; font-weight: bold;">/</span>iostream:<span style="color: #000000;">43</span>:<span style="color: #000000;">28</span>: error: bits<span style="color: #000000; font-weight: bold;">/</span>c++config.h: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory
&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>SDKs<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS4.1.sdk<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>c++<span style="color: #000000; font-weight: bold;">/</span>4.0.0<span style="color: #000000; font-weight: bold;">/</span>iosfwd:<span style="color: #000000;">45</span>:<span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>SDKs<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS4.1.sdk<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>c++<span style="color: #000000; font-weight: bold;">/</span>4.0.0<span style="color: #000000; font-weight: bold;">/</span>iosfwd:<span style="color: #000000;">45</span>:<span style="color: #000000;">29</span>: error: bits<span style="color: #000000; font-weight: bold;">/</span>c++locale.h: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory
&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>SDKs<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS4.1.sdk<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>c++<span style="color: #000000; font-weight: bold;">/</span>4.0.0<span style="color: #000000; font-weight: bold;">/</span>iosfwd:<span style="color: #000000;">46</span>:<span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>SDKs<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS4.1.sdk<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>c++<span style="color: #000000; font-weight: bold;">/</span>4.0.0<span style="color: #000000; font-weight: bold;">/</span>iosfwd:<span style="color: #000000;">46</span>:<span style="color: #000000;">25</span>: error: bits<span style="color: #000000; font-weight: bold;">/</span>c++io.h: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span>,000+ other errors<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<h3>The Solution:</h3>
<p>Set the Base SDK to Mac OS X 10.5 and GCC to 4.2. You&#8217;ll need to make changes to project using the library as well as the libraries Target/Project settings. When you make changes make sure the Target properties displays &#8220;All Configurations&#8221; (i.e. Debug/Release/Release Adhoc/Release AppStore) so that you fix it for all of your build types. Double check and make sure that your static libraries and your project Targets have matching configurations.</p>
<p style="text-align: center;">
<div id="attachment_1000" class="wp-caption aligncenter" style="width: 471px"><a href="http://paulsolt.com/wp-content/uploads/2010/11/Screen-shot-2010-11-16-at-10.14.15-PM.png"><img class="size-full wp-image-1000 " title="Screen shot 2010-11-16 at 10.14.15 PM" src="http://paulsolt.com/wp-content/uploads/2010/11/Screen-shot-2010-11-16-at-10.14.15-PM.png" alt="" width="461" height="480" /></a><p class="wp-caption-text">Using Base SDK: Mac OS X 10.5 and GCC 4.2</p></div>
<h3>Why?</h3>
<p>It may be a simple configuration issue, but I&#8217;m not really sure. For some reason when I use GCC 4.0 it builds against arm and uses the iPhone SDK, but when I use GCC 4.2 it uses the Mac SDK. The library is explicitly targeting Mac OS X 10.4, but it doesn&#8217;t seem to work when it&#8217;s targeting GCC 4.0. Here&#8217;s the comparison build output:</p>
<h4>Base SDK Mac OS X 10.4, GCC 4.0</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">CompileC <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug-CompileC <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug-iphoneos<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>Objects-normal<span style="color: #000000; font-weight: bold;">/</span>armv6<span style="color: #000000; font-weight: bold;">/</span>Canvas.o ..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>source<span style="color: #000000; font-weight: bold;">/</span>Canvas.cpp normal armv6 <span style="color: #c20cb9; font-weight: bold;">c++</span> com.apple.compilers.gcc.4_0
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution<span style="color: #000000; font-weight: bold;">/</span>Xcode<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution
setenv LANG en_US.US-ASCII
setenv PATH <span style="color: #ff0000;">&quot;/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gcc-<span style="color: #000000;">4.0</span> <span style="color: #660033;">-x</span> <span style="color: #c20cb9; font-weight: bold;">c++</span> <span style="color: #660033;">-arch</span> armv6 <span style="color: #660033;">-fmessage-length</span>=<span style="color: #000000;">0</span> <span style="color: #660033;">-pipe</span> <span style="color: #660033;">-Wno-trigraphs</span> <span style="color: #660033;">-fpascal-strings</span> <span style="color: #660033;">-O0</span> <span style="color: #660033;">-Wreturn-type</span> <span style="color: #660033;">-Wunused-variable</span> <span style="color: #660033;">-isysroot</span> <span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>SDKs<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS4.1.sdk <span style="color: #660033;">-mfix-and-continue</span> <span style="color: #660033;">-gdwarf-2</span> <span style="color: #660033;">-mthumb</span> <span style="color: #660033;">-miphoneos-version-min</span>=<span style="color: #000000;">3.2</span> <span style="color: #660033;">-iquote</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug-iphoneos<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib-generated-files.hmap -I<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug-iphoneos<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib-own-target-headers.hmap -I<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug-iphoneos<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib-all-target-headers.hmap <span style="color: #660033;">-iquote</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug-iphoneos<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib-project-headers.hmap -F<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>Debug-iphoneos -I<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>Debug-iphoneos<span style="color: #000000; font-weight: bold;">/</span>include -I<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug-iphoneos<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>DerivedSources<span style="color: #000000; font-weight: bold;">/</span>armv6 -I<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug-iphoneos<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>DerivedSources <span style="color: #660033;">-fvisibility</span>=hidden <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution<span style="color: #000000; font-weight: bold;">/</span>Xcode<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>source<span style="color: #000000; font-weight: bold;">/</span>Canvas.cpp <span style="color: #660033;">-o</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug-iphoneos<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>Objects-normal<span style="color: #000000; font-weight: bold;">/</span>armv6<span style="color: #000000; font-weight: bold;">/</span>Canvas.o</pre></div></div>

<h4>Base SDK Mac OS X 10.5, GCC 4.2</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">CompileC <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>Objects-normal<span style="color: #000000; font-weight: bold;">/</span>x86_64<span style="color: #000000; font-weight: bold;">/</span>Canvas.o <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution<span style="color: #000000; font-weight: bold;">/</span>Xcode<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>source<span style="color: #000000; font-weight: bold;">/</span>Canvas.cpp normal x86_64 <span style="color: #c20cb9; font-weight: bold;">c++</span> com.apple.compilers.gcc.4_2
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution<span style="color: #000000; font-weight: bold;">/</span>Xcode<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution
setenv LANG en_US.US-ASCII
<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gcc-<span style="color: #000000;">4.2</span> <span style="color: #660033;">-x</span> <span style="color: #c20cb9; font-weight: bold;">c++</span> <span style="color: #660033;">-arch</span> x86_64 <span style="color: #660033;">-fmessage-length</span>=<span style="color: #000000;">0</span> <span style="color: #660033;">-pipe</span> <span style="color: #660033;">-Wno-trigraphs</span> <span style="color: #660033;">-fpascal-strings</span> <span style="color: #660033;">-fasm-blocks</span> <span style="color: #660033;">-O0</span> <span style="color: #660033;">-Wreturn-type</span> <span style="color: #660033;">-Wunused-variable</span> <span style="color: #660033;">-isysroot</span> <span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>SDKs<span style="color: #000000; font-weight: bold;">/</span>MacOSX10.5.sdk <span style="color: #660033;">-mfix-and-continue</span> <span style="color: #660033;">-mmacosx-version-min</span>=<span style="color: #000000;">10.5</span> <span style="color: #660033;">-gdwarf-2</span> <span style="color: #660033;">-iquote</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib-generated-files.hmap -I<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib-own-target-headers.hmap -I<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib-all-target-headers.hmap <span style="color: #660033;">-iquote</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib-project-headers.hmap -F<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>Debug -I<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>Debug<span style="color: #000000; font-weight: bold;">/</span>include -I<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>DerivedSources<span style="color: #000000; font-weight: bold;">/</span>x86_64 -I<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>DerivedSources <span style="color: #660033;">-fvisibility</span>=hidden <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution<span style="color: #000000; font-weight: bold;">/</span>Xcode<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>source<span style="color: #000000; font-weight: bold;">/</span>Canvas.cpp <span style="color: #660033;">-o</span> <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>paulsolt<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xcode_build_output<span style="color: #000000; font-weight: bold;">/</span>ArtworkEvolution.build<span style="color: #000000; font-weight: bold;">/</span>Debug<span style="color: #000000; font-weight: bold;">/</span>MacEvolutionLib.build<span style="color: #000000; font-weight: bold;">/</span>Objects-normal<span style="color: #000000; font-weight: bold;">/</span>x86_64<span style="color: #000000; font-weight: bold;">/</span>Canvas.o</pre></div></div>

<h3>Notes:</h3>
<p>GCC 4.2 is required for 10.5, if you try and use the Base SDK of 10.4 and GCC 4.2 you&#8217;ll get this error.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">GCC <span style="color: #000000;">4.2</span> is not compatible with the Mac OS X <span style="color: #000000;">10.4</span> SDK</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://paulsolt.com/2010/11/objective-cc-iphone-build-failures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GLUT Object Oriented Framework on Github</title>
		<link>http://paulsolt.com/2010/08/glut-object-oriented-framework-on-github/</link>
		<comments>http://paulsolt.com/2010/08/glut-object-oriented-framework-on-github/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 06:30:09 +0000</pubDate>
		<dc:creator>Paul Solt</dc:creator>
				<category><![CDATA[Computer Graphics]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[computer animation]]></category>
		<category><![CDATA[cross platform]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[GLUT]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[object oriented wrapper]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://paulsolt.com/?p=610</guid>
		<description><![CDATA[<p>In 2009 I took a Computer Animation course at @RIT I created an object-oriented C++ wrapper for GLUT. The idea was to create a set of classes that could be reused for each of the separate project submissions. The main class wraps around the GLUT C-style functions and provides a class that can be inherited [...]]]></description>
			<content:encoded><![CDATA[<p>In 2009 I took a Computer Animation course at @RIT I created an object-oriented C++ wrapper for GLUT. The idea was to create a set of classes that could be reused for each of the separate project submissions. The main class wraps around the GLUT C-style functions and provides a class that can be inherited from, to provide application specific functionality.</p>
<p>The idea was to make the boiler plate code disappear and make it easier for novice programmers to get an animated graphics window in as few lines as possible. Only four lines of code are needed to get the window running at 60 frames per second. You can subclass the framework and implement your own OpenGL animation or game project.</p>
<p><strong>Edit (8/22/10)</strong>: You don&#8217;t need to use pointers, I&#8217;ve updated the code example with working code.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// main.cpp</span>
<span style="color: #339900;">#include &quot;GlutFramework.h&quot;</span>
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> glutFramework<span style="color: #008080;">;</span>
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>argv<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	GlutFramework framework<span style="color: #008080;">;</span>
	framework.<span style="color: #007788;">startFramework</span><span style="color: #008000;">&#40;</span>argc, argv<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
        <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-2182421302031373";
/* Large Post Ad */
google_ad_slot = "4358587115";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>The code uses a cross-platform (Windows/Mac tested) timer to create a constant frame-rate, which is necessary for animation projects. It&#8217;s under the MIT License, so feel free to use it as you see fit.<br />
<a href=" http://github.com/PaulSolt/GLUT-Object-Oriented-Framework"></p>
<p>http://github.com/PaulSolt/GLUT-Object-Oriented-Framework</a></p>
<p>An Xcode 3.1 and Visual Studio 2010 project is hosted on github to support Mac and Windows. There is no setup on the Mac, but Windows users will need to configure GLUT. I plan on posted tutorials on how to get setup on both platforms. For now, look at the resources section below.</p>
<div id="attachment_617" class="wp-caption aligncenter" style="width: 514px"><a href="http://paulsolt.com/wp-content/uploads/2010/08/teapot.png"><img class="size-full wp-image-617 " title="teapot" src="http://paulsolt.com/wp-content/uploads/2010/08/teapot.png" alt="" width="504" height="407" /></a><p class="wp-caption-text">Animated teapot</p></div>
<p>Resources:</p>
<ul>
<li>Previous Post: <a href="http://paulsolt.com/2009/07/openglglut-classes-oop-and-problems/">http://paulsolt.com/2009/07/openglglut-classes-oop-and-problems/</a></li>
<li>GLUT for Windows: <a href="http://www.xmission.com/~nate/glut.html ">http://www.xmission.com/~nate/glut.html </a></li>
<li>Visual Studio and GLUT setup: <a href="http://www.cs.uiowa.edu/~cwyman/classes/common/howto/winGLUT.html">http://www.cs.uiowa.edu/~cwyman/classes/common/howto/winGLUT.html</a></li>
<li>Old Post on GLUT in Eclipse: <a href="http://www.paulsolt.com/GLUT/">http://www.paulsolt.com/GLUT/</a></li>
</ul>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-2182421302031373";
/* Large Post Ad */
google_ad_slot = "4358587115";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://paulsolt.com/2010/08/glut-object-oriented-framework-on-github/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>C++ Logging and building Boost for iPhone/iPad 3.2 and MacOSX</title>
		<link>http://paulsolt.com/2010/04/c-logging-and-building-boost-for-iphoneipad-3-2-and-macosx/</link>
		<comments>http://paulsolt.com/2010/04/c-logging-and-building-boost-for-iphoneipad-3-2-and-macosx/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 05:15:42 +0000</pubDate>
		<dc:creator>Paul Solt</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Boost]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone 3.2]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://paulsolt.com/?p=559</guid>
		<description><![CDATA[<p style="text-align: justify;">In my effort to write more robust and maintainable code I have been searching for a cross-platform C++ logging utility. I&#8217;m working on a C++ static library for iPhone/iPad 3.2/Mac/Windows and I needed a way to log what was happening in my library. Along the way I was forced to build Boost for [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">In my effort to write more robust and maintainable code I have been searching for a cross-platform C++ logging utility. I&#8217;m working on a C++ static library for iPhone/iPad 3.2/Mac/Windows and I needed a way to log what was happening in my library. Along the way I was forced to build Boost for iPhone, iPhone Simulator, and the Mac.</p>
<h2 style="text-align: justify;">Why logging?</h2>
<p style="text-align: justify;">Mobile devices lack a console when detached from a development machine, so it&#8217;s hard to track down issues. I needed a system that could log at multiple levels (Debug1, Debug2, Info, Error, Warning) and be thread safe. Multiple logger levels allow a developer to turn up/down the detail of information that is stored, which in turn affect performance with I/O writes. A developer with logging information can better track down crashes and other issues during an applications lifetime.</p>
<h2 style="text-align: justify;">Why Boost Logger Library v2?</h2>
<p style="text-align: justify;">I struggled trying to get a logger working. After many failed attempts with <a href="http://pantheios.sourceforge.net/">Pantheios</a>, <a href="http://logging.apache.org/log4cxx/">log4cxx</a>, <a href="http://log4cpp.sourceforge.net/">log4cpp</a>, and <a href="http://code.google.com/p/google-glog/">glog</a>, I settled on the <a href="http://torjo.com/log2/">Boost Logger Library v2</a> because I was able to &#8220;compile&#8221; for iPhone/iPad 3.2 and Mac OSX. Most of the loggers required other dependencies that would need to be rebuilt for iPhone and didn&#8217;t directly support iPhone.</p>
<p style="text-align: justify;">The Boost Logger is all header files so it doesn&#8217;t require &#8220;compiling,&#8221; which made it much easier to get working. However, it does require a few Boost libraries that need to be compiled. The Boost Logging needs the following libraries: filesystem, system, and threading depending on what functionality is used.</p>
<h3>Step 1: Building Boost for iPhone/iPad and iPhone Simulator 3.2</h3>
<p style="text-align: justify;">A few Boost libraries need compiling for the iPhone/iPad and the iPhone Simulator in order to link against the Boost Logger. <a href="http://iphone.galloway.me.uk/2009/11/compiling-boost-for-the-iphone/">Matt Galloway</a> provided a demo on how to compile Boost 1.41/1.42 for iPhone/iPhone Simulator. Here are the steps I used for Boost 1.42 based on his tutorial.</p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-2182421302031373";
/* Large Post Ad */
google_ad_slot = "4358587115";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<ol>
<li>Get <a href="http://www.boost.org/users/news/version_1_42_0">Boost 1.42</a></li>
<li>Extract Boost:</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> xzf boost_1_42_0.tar.gz</pre></div></div>

<li>Create a user-config.jam file in your user directory (~/user-config.jam) such as /Users/paulsolt/user-config.jam with the following. (<strong>Note</strong>:  this config file needs to be rename or moved during the MacOSX bjam build)</li>
<p><code><br />
</code><br />
~/user-config.jam</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">using darwin : 4.2.1~iphone
   : <span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneOS.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gcc-<span style="color: #000000;">4.2</span> <span style="color: #660033;">-arch</span> armv7 <span style="color: #660033;">-mthumb</span> <span style="color: #660033;">-fvisibility</span>=hidden <span style="color: #660033;">-fvisibility-inlines-hidden</span>
   : <span style="color: #000000; font-weight: bold;">&lt;</span>striper<span style="color: #000000; font-weight: bold;">&gt;</span>
   : <span style="color: #000000; font-weight: bold;">&lt;</span>architecture<span style="color: #000000; font-weight: bold;">&gt;</span>arm <span style="color: #000000; font-weight: bold;">&lt;</span>target-os<span style="color: #000000; font-weight: bold;">&gt;</span>iphone <span style="color: #000000; font-weight: bold;">&lt;</span>macosx-version<span style="color: #000000; font-weight: bold;">&gt;</span>iphone-<span style="color: #000000;">3.2</span>
   ;
&nbsp;
using darwin : 4.2.1~iphonesim
   : <span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>Platforms<span style="color: #000000; font-weight: bold;">/</span>iPhoneSimulator.platform<span style="color: #000000; font-weight: bold;">/</span>Developer<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gcc-<span style="color: #000000;">4.2</span> <span style="color: #660033;">-arch</span> i386 <span style="color: #660033;">-fvisibility</span>=hidden <span style="color: #660033;">-fvisibility-inlines-hidden</span>
   : <span style="color: #000000; font-weight: bold;">&lt;</span>striper<span style="color: #000000; font-weight: bold;">&gt;</span>
   : <span style="color: #000000; font-weight: bold;">&lt;</span>architecture<span style="color: #000000; font-weight: bold;">&gt;</span>x86 <span style="color: #000000; font-weight: bold;">&lt;</span>target-os<span style="color: #000000; font-weight: bold;">&gt;</span>iphone <span style="color: #000000; font-weight: bold;">&lt;</span>macosx-version<span style="color: #000000; font-weight: bold;">&gt;</span>iphonesim-<span style="color: #000000;">3.2</span>
   ;</pre></div></div>

<li>Make sure the file <em>boost_1_42_0/tools/build/v2/tools/darwin.jam</em> has the following information:</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">tools<span style="color: #000000; font-weight: bold;">/</span>build<span style="color: #000000; font-weight: bold;">/</span>v2<span style="color: #000000; font-weight: bold;">/</span>tools<span style="color: #000000; font-weight: bold;">/</span>darwin.jam
<span style="color: #666666; font-style: italic;">## The MacOSX versions we can target.</span>
.macosx-versions =
    <span style="color: #000000;">10.6</span> <span style="color: #000000;">10.5</span> <span style="color: #000000;">10.4</span> <span style="color: #000000;">10.3</span> <span style="color: #000000;">10.2</span> <span style="color: #000000;">10.1</span>
    iphone-<span style="color: #000000;">3.2</span> iphonesim-<span style="color: #000000;">3.2</span>
    iphone-3.1.3 iphonesim-3.1.3
    iphone-3.1.2 iphonesim-3.1.2
    iphone-<span style="color: #000000;">3.1</span> iphonesim-<span style="color: #000000;">3.1</span>
    iphone-<span style="color: #000000;">3.0</span> iphonesim-<span style="color: #000000;">3.0</span>
    iphone-2.2.1 iphonesim-2.2.1
    iphone-<span style="color: #000000;">2.2</span> iphonesim-<span style="color: #000000;">2.2</span>
    iphone-<span style="color: #000000;">2.1</span> iphonesim-<span style="color: #000000;">2.1</span>
    iphone-<span style="color: #000000;">2.0</span> iphonesim-<span style="color: #000000;">2.0</span>
    iphone-<span style="color: #000000;">1</span>.x
    ;</pre></div></div>

<li>Change directories to the Boost directory that you downloaded:</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>boost_1_42_0</pre></div></div>

<li style="text-align: justify;">Run the following commands to compile the iPhone and iPhone Simulator Boost libraries. I only need filesystem, system, and thread to be use Boost logging for the iPhone, so I don&#8217;t build everything. Run ./bootstrap.sh &#8211;help or ./bjam &#8211;help for more options. I built the binaries to a location in my development folder to include in my project dependencies.</li>
<p><code><br />
</code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>bootstrap.sh <span style="color: #660033;">--with-libraries</span>=filesystem,system,thread</pre></div></div>

<p><code><br />
</code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>bjam <span style="color: #660033;">--prefix</span>=<span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>boost<span style="color: #000000; font-weight: bold;">/</span>iphone <span style="color: #007800;">toolset</span>=darwin <span style="color: #007800;">architecture</span>=arm target-os=iphone macosx-version=iphone-<span style="color: #000000;">3.2</span> <span style="color: #007800;">define</span>=_LITTLE_ENDIAN <span style="color: #007800;">link</span>=static <span style="color: #c20cb9; font-weight: bold;">install</span>
.<span style="color: #000000; font-weight: bold;">/</span>bjam <span style="color: #660033;">--prefix</span>=<span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>boost<span style="color: #000000; font-weight: bold;">/</span>iphoneSimulator <span style="color: #007800;">toolset</span>=darwin <span style="color: #007800;">architecture</span>=x86 target-os=iphone macosx-version=iphonesim-<span style="color: #000000;">3.2</span> <span style="color: #007800;">link</span>=static <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<li style="text-align: justify;"><strong>Update: </strong>Create a universal Boost Library using the lipo tool. In this example I&#8217;m assuming the binaries that were created have the following names. The names from the bjam generation will be different, based on your own configuration.<strong>End Update</strong></li>
<p style="text-align: center;"><code><script type="text/javascript"><!--
google_ad_client = "pub-2182421302031373";
/* 468x15, created 11/9/10 */
google_ad_slot = "7180498408";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
</code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">lipo <span style="color: #660033;">-create</span> libboost_filesystem_iphone.a libboost_filesystem_iphonesimulator.a <span style="color: #660033;">-output</span> libboost_filesystem_iphone_universal.a
&nbsp;
lipo <span style="color: #660033;">-create</span> libboost_system_iphone.a libboost_system_iphonesimulator.a <span style="color: #660033;">-output</span> libboost_system_iphone_universal.a
&nbsp;
lipo <span style="color: #660033;">-create</span> libboost_thread_iphone.a libboost_thread_iphonesimulator.a <span style="color: #660033;">-output</span> libboost_thread_iphone_universal.a</pre></div></div>

<li style="text-align: justify;">I&#8217;m working on a cross-platform project and my directory structure looks like the following structure. I copied the include and lib files for iPhone and iPhone Simulator into the appropriate directories. The dependency structure allows me to checkout the project on another machine and have relative references to Boost and other dependencies.</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">   <span style="color: #000000; font-weight: bold;">|</span>-ArtworkEvolution
   <span style="color: #000000; font-weight: bold;">|</span>---Xcode
   <span style="color: #000000; font-weight: bold;">|</span>-----BoostLoggingTest
   <span style="color: #000000; font-weight: bold;">|</span>---dependencies
   <span style="color: #000000; font-weight: bold;">|</span>-----iphone
   <span style="color: #000000; font-weight: bold;">|</span>-------debug
   <span style="color: #000000; font-weight: bold;">|</span>-------release
   <span style="color: #000000; font-weight: bold;">|</span>---------include
   <span style="color: #000000; font-weight: bold;">|</span>-----------boost
   <span style="color: #000000; font-weight: bold;">|</span>---------lib
   <span style="color: #000000; font-weight: bold;">|</span>-----iphone-simulator
   <span style="color: #000000; font-weight: bold;">|</span>-------debug
   <span style="color: #000000; font-weight: bold;">|</span>-------release
   <span style="color: #000000; font-weight: bold;">|</span>---------include
   <span style="color: #000000; font-weight: bold;">|</span>-----------boost
   <span style="color: #000000; font-weight: bold;">|</span>---------lib
   <span style="color: #000000; font-weight: bold;">|</span>-----macosx
   <span style="color: #000000; font-weight: bold;">|</span>-------debug
   <span style="color: #000000; font-weight: bold;">|</span>-------release
   <span style="color: #000000; font-weight: bold;">|</span>---------include
   <span style="color: #000000; font-weight: bold;">|</span>-----------boost
   <span style="color: #000000; font-weight: bold;">|</span>-----------libs
   <span style="color: #000000; font-weight: bold;">|</span>-----win32
   <span style="color: #000000; font-weight: bold;">|</span>---docs
   <span style="color: #000000; font-weight: bold;">|</span>---source
   <span style="color: #000000; font-weight: bold;">|</span>---tests</pre></div></div>

<li style="text-align: justify;">Download the <a href="http://torjo.com/log2/">Boost Logging Library v2</a> and unzip it.</li>
<li style="text-align: justify;">Copy and paste the logging folder into each include/boost folder for iPhone and iPhone Simulator dependency folders like in my directory structure. After you unzip the header files are located in the folder logging/boost/logging.</li>
</ol>
<h4 style="text-align: justify;">Step 2:  Creating the Xcode Project</h4>
<p style="text-align: justify;">With the iPhone and iPhone Simulator Boost libraries in hand we&#8217;re ready to make an Xcode project. Due to the difference in the iPhone and iPhone Simulator libraries we&#8217;ll need to make two targets. One will build linking against the iPhone Boost libraries (arm) and the other against the iPhone Boost Simulator libraries (x86).</p>
<p style="text-align: justify;"><strong>Update:</strong> You don&#8217;t need to create two targets, as we can use the lipo tool to make a universal iPhone/iPhone Simulator library file. The universal library file can be shared between iPhone and iPhone Simulator build configurations. See the instructions for using lipo to create the universal library files in the previous section. However, I will keep the two target instructions up as an alternate approach for Xcode project development, if you choose not to use the lipo tool.</p>
<p style="text-align: justify;"><strong>End Update</strong></p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-2182421302031373";
/* 468x15, created 11/9/10 */
google_ad_slot = "7180498408";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p style="text-align: justify;">1. Create a new iPhone project (view based)</p>
<p style="text-align: justify;">2. There will be two targets: &#8220;BoostLoggingTest Device&#8221; and &#8220;BoostLogging Test Simulator&#8221; each will reference different headers and libraries. Duplicate the starting target and rename each target respectively.</p>
<div id="attachment_566" class="wp-caption aligncenter" style="width: 502px"><a href="http://paulsolt.com/wp-content/uploads/2010/04/Screen-shot-2010-04-06-at-7.43.21-PM.png"><img class="size-full wp-image-566 " title="Screen shot 2010-04-06 at 7.43.21 PM" src="http://paulsolt.com/wp-content/uploads/2010/04/Screen-shot-2010-04-06-at-7.43.21-PM.png" alt="" width="492" height="427" /></a><p class="wp-caption-text">Duplicate target to make iPhone/iPhoneSimulator targets</p></div>
<p style="text-align: justify;">3. Add the libraries that we compiled into two groups: device and simulator under Resources. Right-click on the group &#8220;Simulator&#8221; or &#8220;Device&#8221; and select &#8220;Add Existing Files&#8221;. Search for the library .a files that you copied into the iphone and iphone-simulator directories. These resources should be added relative to the project folder.</p>
<p style="text-align: justify;">4. Drag the appropriate libraries to each Target. We need two targets since the architecture is different on the iPhone device (arm) versus the iPhone Simulator (Intel x86).</p>
<div id="attachment_569" class="wp-caption aligncenter" style="width: 486px"><a href="http://paulsolt.com/wp-content/uploads/2010/04/DragDeviceLibraries.png"><img class="size-full wp-image-569 " title="DragDeviceLibraries" src="http://paulsolt.com/wp-content/uploads/2010/04/DragDeviceLibraries.png" alt="" width="476" height="431" /></a><p class="wp-caption-text">Drag the device libraries to the device target.</p></div>
<div id="attachment_570" class="wp-caption aligncenter" style="width: 486px"><a href="http://paulsolt.com/wp-content/uploads/2010/04/DragSimulatorLibraries.png"><img class="size-full wp-image-570 " title="DragSimulatorLibraries" src="http://paulsolt.com/wp-content/uploads/2010/04/DragSimulatorLibraries.png" alt="" width="476" height="431" /></a><p class="wp-caption-text">Drag simulator dependencies to the iPhone simulator target</p></div>
<p style="text-align: justify;">5. Add the &#8220;Header Search Path&#8221; for each target. For me the relative path will be two directories up from the Xcode project folders:  <em>../../dependencies/iphone/release/include</em> and <em>../../dependencies/iphone-simulator/release/include.</em> Right-click on each Target in the left pane and click on &#8220;Get Info&#8221; -&gt; Build -&gt; Type &#8220;Header&#8221; in the search field -&gt; Edit the list of paths.</p>
<div id="attachment_571" class="wp-caption aligncenter" style="width: 522px"><a href="http://paulsolt.com/wp-content/uploads/2010/04/Device-Header-Path.png"><img class="size-full wp-image-571   " title="Device Header Path" src="http://paulsolt.com/wp-content/uploads/2010/04/Device-Header-Path.png" alt="" width="512" height="471" /></a><p class="wp-caption-text">Add the Device Target Header Search path for the boost libraries</p></div>
<div id="attachment_572" class="wp-caption aligncenter" style="width: 528px"><a href="http://paulsolt.com/wp-content/uploads/2010/04/Simulator-Header-Path.png"><img class="size-full wp-image-572 " title="Simulator Header Path" src="http://paulsolt.com/wp-content/uploads/2010/04/Simulator-Header-Path.png" alt="" width="518" height="471" /></a><p class="wp-caption-text">Add the simulator targets Header Search Paths</p></div>
<p style="text-align: justify;">6. Change the base SDK of each target. For the Device you need to use <em>iPhone Device 3.2</em> and the Simulator Target needs <em>iPhone Simulator 3.2</em> or later.</p>
<div id="attachment_573" class="wp-caption aligncenter" style="width: 441px"><a href="http://paulsolt.com/wp-content/uploads/2010/04/Device-Base-SDK.png"><img class="size-full wp-image-573 " title="Device Base SDK" src="http://paulsolt.com/wp-content/uploads/2010/04/Device-Base-SDK.png" alt="" width="431" height="471" /></a><p class="wp-caption-text">Set the Device Target to iPhone Device 3.2</p></div>
<div id="attachment_574" class="wp-caption aligncenter" style="width: 441px"><a href="http://paulsolt.com/wp-content/uploads/2010/04/Simulator-Base-SDK.png"><img class="size-full wp-image-574 " title="Simulator Base SDK" src="http://paulsolt.com/wp-content/uploads/2010/04/Simulator-Base-SDK.png" alt="" width="431" height="471" /></a><p class="wp-caption-text">Set the Simulator Target to iPhone Simulator 3.2</p></div>
<p style="text-align: justify;">7. Now you have two different targets. One is for the iPhone Device and the other is for the iPhone Simulator. We did this because we built separate binaries for Boost on the iPhone (arm) and simulator (x86) platforms.</p>
<p style="text-align: justify;">8. Set the project&#8217;s <em>Active SDK</em> to use the Base SDK (top left of Xcode). Now it will automatically choose the iPhone Device or iPhone Simulator based on the Base SDK of each Target you select.</p>
<p style="text-align: justify;">
<p style="text-align: justify;">9. Logging on the iPhone requires that we use the full path to the file within the application sandbox. Use the following Objective-C code to get it:</p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-2182421302031373";
/* 468x15, created 11/9/10 */
google_ad_slot = "7180498408";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>docsDirectory <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>NSSearchPathForDirectoriesInDomains<span style="color: #002200;">&#40;</span>NSDocumentDirectory, NSUserDomainMask, <span style="color: #a61390;">YES</span><span style="color: #002200;">&#41;</span> objectAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>path <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>docsDirectory stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;err.txt&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #a61390;">const</span> <span style="color: #a61390;">char</span> <span style="color: #002200;">*</span>outputFilename <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>path UTF8String<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p style="text-align: justify;">10. I modified one of the Boost Logging samples to use the full file path on the iPhone. Rename the main.m as main.mm to use Objective-C/C++ and copy paste the following:  <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre;"><a href="http://paulsolt.com/wp-content/uploads/2010/04/main.txt">main.mm code</a></span></p>
<p style="text-align: justify;">11. If everything compiled and ran on the Device you can get the application data from the Xcode Organizer (Option+Command+O) Navigate to Devices and then look in Applications for the test application. Just drag the &#8220;Application Data&#8221; to your desktop to download it from the device. Your logs should appear in the Documents folder.</p>
<p style="text-align: center;">
<h4 style="text-align: justify;">Part 3: Build Boost for Mac OS X 10.6 &#8211; 4 way fat (32/64 PPC and 32/64 Intel)</h4>
<p style="text-align: justify;">1. Build boost for Mac OS X. <strong>Note</strong>:  If you setup the user-config.jam file for iPhone Boost build, rename or move the file to a different folder than your home directory, otherwise ignore this command.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mv</span> ~<span style="color: #000000; font-weight: bold;">/</span>user-config.jam ~<span style="color: #000000; font-weight: bold;">/</span>user-config.jam.INACTIVE</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>boost_1_42_0
.<span style="color: #000000; font-weight: bold;">/</span>bootstrap.sh <span style="color: #660033;">--with-libraries</span>=filesystem,system,thread
.<span style="color: #000000; font-weight: bold;">/</span>bjam <span style="color: #660033;">--prefix</span>=<span style="color: #800000;">${HOME}</span><span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>boost<span style="color: #000000; font-weight: bold;">/</span>macosx <span style="color: #007800;">toolset</span>=darwin <span style="color: #007800;">architecture</span>=combined address-model=<span style="color: #000000;">32</span>_64 <span style="color: #007800;">link</span>=static <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p style="text-align: justify;">2. Copy the output into your dependency structure and add the Boost Logging Library headers into the include/boost folder. (Same procedure as with iPhone)</p>
<p style="text-align: justify;">3. Setup a Xcode project or target with the appropriate header search path, Boost Mac OSX libraries in the same way we setup the iPhone Xcode project.</p>
<p style="text-align: justify;"><strong>Note: </strong>If you get warnings about hidden symbols and default settings open the Xcode project for and make sure that the &#8220;Inline Methods Hidden&#8221; and &#8220;Symbols Hidden by Default&#8221; are unchecked. Clicking on/off might fix any Xcode warnings.</p>
<p style="text-align: center;"><a href="http://paulsolt.com/wp-content/uploads/2010/04/Hidden-Symbols-Off.png"><img class="aligncenter size-full wp-image-576" title="Hidden Symbols Off" src="http://paulsolt.com/wp-content/uploads/2010/04/Hidden-Symbols-Off.png" alt="" width="431" height="471" /></a></p>
<h5>References:</h5>
<ul>
<li><a href="http://iphone.galloway.me.uk/2009/11/compiling-boost-for-the-iphone/" target="_blank">http://iphone.galloway.me.uk/2009/11/compiling-boost-for-the-iphone/</a></li>
<li><a href="http://brockwoolf.com/blog/compile-and-use-boost-libraries-in-xcode-visual-studio">http://brockwoolf.com/blog/compile-and-use-boost-libraries-in-xcode-visual-studio</a></li>
</ul>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-2182421302031373";
/* Large Post Ad */
google_ad_slot = "4358587115";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://paulsolt.com/2010/04/c-logging-and-building-boost-for-iphoneipad-3-2-and-macosx/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>iPhone Player/Stage Remote Control</title>
		<link>http://paulsolt.com/2009/08/iphone-playerstage-remote-control/</link>
		<comments>http://paulsolt.com/2009/08/iphone-playerstage-remote-control/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 08:28:44 +0000</pubDate>
		<dc:creator>Paul Solt</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[player/stage]]></category>
		<category><![CDATA[remote control]]></category>
		<category><![CDATA[robotics]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://paulsolt.com/?p=329</guid>
		<description><![CDATA[<p>Here&#8217;s the iPhone Player/Stage Remote Control project! There&#8217;s a .pdf that describes how to setup Xcode in the .zip file.</p> <p style="text-align: center;"> <p>The goal of this project was to use the Player/Stage robotics code on the iPhone to communicate and control robots. I discuss how to setup the Xcode development environment. There are two [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the iPhone Player/Stage Remote Control project! There&#8217;s a .pdf that describes how to setup Xcode in the .zip file.</p>
<p style="text-align: center;">
<div id="attachment_456" class="wp-caption aligncenter" style="width: 549px"><a href="http://paulsolt.com/wp-content/uploads/2009/08/RRemoteiPhone.png"><img class="size-full wp-image-456 " title="RRemoteiPhone" src="http://paulsolt.com/wp-content/uploads/2009/08/RRemoteiPhone.png" alt="" width="539" height="290" /></a><p class="wp-caption-text">Controlling a Robot over Wi-Fi</p></div>
<div id="attachment_455" class="wp-caption aligncenter" style="width: 506px"><a href="http://paulsolt.com/wp-content/uploads/2009/08/PlayerStage.png"><img class="size-full wp-image-455 " title="PlayerStage" src="http://paulsolt.com/wp-content/uploads/2009/08/PlayerStage.png" alt="" width="496" height="510" /></a><p class="wp-caption-text">A Virtual Robot in a Virtual World</p></div>
<p>The goal of this project was to use the Player/Stage robotics code on the iPhone to communicate and control robots. I discuss how to setup the  Xcode development environment. There are two example Xcode projects. The first one is an Objective-C project that wraps around the C++ Player/Stage code. The second project is a very primitive C++ program running on the iPhone without any UI. Both of these Xcode projects are fully documented and will serve as a starting point to iPhone Player/Stage development.</p>
<p>iPhone Player/Stage Remote Control Project: <a href="http://paulsolt.com/wp-content/uploads/2009/08/iPhonePlayerStage.zip">iPhonePlayerStage</a></p>
<p>Feel free to ask questions and let me know how you use the code.</p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-2182421302031373";
/* Large Post Ad */
google_ad_slot = "4358587115";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://paulsolt.com/2009/08/iphone-playerstage-remote-control/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>OpenGL/GLUT, Classes (OOP), and Problems</title>
		<link>http://paulsolt.com/2009/07/openglglut-classes-oop-and-problems/</link>
		<comments>http://paulsolt.com/2009/07/openglglut-classes-oop-and-problems/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 06:59:30 +0000</pubDate>
		<dc:creator>Paul Solt</dc:creator>
				<category><![CDATA[Animation Project]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[function pointers]]></category>
		<category><![CDATA[GLUT]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[member functions]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[polymorphism]]></category>
		<category><![CDATA[static methods]]></category>

		<guid isPermaLink="false">http://paulsolt.com/?p=156</guid>
		<description><![CDATA[<p>Update: 8/22/10 Checkout the updated framework and post: <a href="http://paulsolt.com/2010/08/glut-object-oriented-framework-on-github/">http://paulsolt.com/2010/08/glut-object-oriented-framework-on-github/</a></p> <p>I created a C style driver program that used OpenGL/GLUT for my <a href="http://paulsolt.com/projects/computer-animation/">computer animation course projects</a>. It worked fine for the first project. However, there were multiple projects and they all started to use the same boiler plate code. In order to reuse code, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update: 8/22/10</strong> Checkout the updated framework and post: <a href="http://paulsolt.com/2010/08/glut-object-oriented-framework-on-github/">http://paulsolt.com/2010/08/glut-object-oriented-framework-on-github/</a></p>
<p>I created a C style driver program that used OpenGL/GLUT for my <a href="http://paulsolt.com/projects/computer-animation/">computer animation course projects</a>. It worked fine for the first project. However, there were multiple projects and they all started to use the same boiler plate code. In order to reuse code, I decided to refactor and make an extensible class to setup GLUT. My goal was to make it easy to extend the core behavior of the GLUT/OpenGL application.</p>
<p>As I refactored the code I decided to make a base class to perform all the GLUT setup. There&#8217;s a first time for everything and I didn&#8217;t realize the scope of this change until I was committed to it. I will summarize the problems and how to solve them. The code and explanations should provide the basic understanding of what is happening, but it will not compile as it is provided.</p>
<p><strong>Problem 1</strong>: My initial attempt was to pass member functions to the GLUT callback functions. However, you can&#8217;t pass member functions from a class directly to C callback functions. The GLUT callback functions expect a function signature exactly as <strong>function(BLAH)</strong> and I was giving it something that was <strong>function(this, BLAH)</strong>. Where the &#8220;this&#8221; portion was the object passed under the hood.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> AnimationFramework <span style="color: #008000;">&#123;</span>
<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
	<span style="color: #0000ff;">void</span> display<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">void</span> run<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">void</span> keyboard<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">void</span> keyboardUp<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">void</span> specialKeyboard<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">void</span> specialKeyboard<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">void</span> startFramework<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>argv<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span></pre></div></div>

<p>&#8230; in the setup function for GLUT</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> AnimationFramework<span style="color: #008080;">::</span><span style="color: #007788;">startFramework</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>argv<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	<span style="color: #666666;">// Initialize GLUT</span>
	glutInit<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>argc, argv<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	glutInitDisplayMode<span style="color: #008000;">&#40;</span>GLUT_RGB <span style="color: #000040;">|</span> GLUT_DOUBLE <span style="color: #000040;">|</span> GLUT_DEPTH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	glutInitWindowPosition<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">300</span>, <span style="color: #0000dd;">100</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	glutInitWindowSize<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">600</span>, <span style="color: #0000dd;">480</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	glutCreateWindow<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;Animation Framework&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
&nbsp;
	<span style="color: #666666;">// Function callbacks</span>
	glutDisplayFunc<span style="color: #008000;">&#40;</span>display<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 		<span style="color: #666666;">// ERROR</span>
	glutKeyboardFunc<span style="color: #008000;">&#40;</span>keyboard<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 		<span style="color: #666666;">// ERROR</span>
	glutKeyboardUpFunc<span style="color: #008000;">&#40;</span>keyboardUp<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 	<span style="color: #666666;">// ERROR</span>
	glutSpecialFunc<span style="color: #008000;">&#40;</span>specialKeyboard<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 	<span style="color: #666666;">// ERROR</span>
	glutSpecialUpFunc<span style="color: #008000;">&#40;</span>specialKeyboardUp<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// ERROR</span>
&nbsp;
	init<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>			<span style="color: #666666;">// Initialize</span>
	glutIdleFunc<span style="color: #008000;">&#40;</span>run<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 	<span style="color: #666666;">// The program run loop  // ERROR</span>
	glutMainLoop<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>		<span style="color: #666666;">// Start the main GLUT thread</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p><strong>Solution 1</strong>: Create static methods, and pass these static methods to the call back functions. All the logic for the AnimationFramework will go into these static methods. I&#8217;ve fixed the compiler errors, but it feels like a step backwards from what I set out to do.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> AnimationFramework <span style="color: #008000;">&#123;</span>
<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> displayWrapper<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> runWrapper<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> keyboardWrapper<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> keyboardUpWrapper<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> specialKeyboardWrapper<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> specialKeyboardUpWrapper<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">void</span> startFramework<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>argv<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span></pre></div></div>

<p>&#8230; in a setup function for GLUT</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">void</span> AnimationFramework<span style="color: #008080;">::</span><span style="color: #007788;">startFramework</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>argv<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	<span style="color: #666666;">// Initialize GLUT</span>
	glutInit<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>argc, argv<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	glutInitDisplayMode<span style="color: #008000;">&#40;</span>GLUT_RGB <span style="color: #000040;">|</span> GLUT_DOUBLE <span style="color: #000040;">|</span> GLUT_DEPTH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	glutInitWindowPosition<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">300</span>, <span style="color: #0000dd;">100</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	glutInitWindowSize<span style="color: #008000;">&#40;</span><span style="color: #0000dd;">600</span>, <span style="color: #0000dd;">480</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	glutCreateWindow<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;Animation Framework&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 
&nbsp;
	<span style="color: #666666;">// Function callbacks</span>
	glutDisplayFunc<span style="color: #008000;">&#40;</span>displayWrapper<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>		<span style="color: #666666;">// NO ERRORS!</span>
	glutKeyboardFunc<span style="color: #008000;">&#40;</span>keyboardWrapper<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	glutKeyboardUpFunc<span style="color: #008000;">&#40;</span>keyboardUpWrapper<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	glutSpecialFunc<span style="color: #008000;">&#40;</span>specialKeyboardWrapper<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	glutSpecialUpFunc<span style="color: #008000;">&#40;</span>specialKeyboardUpWrapper<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	init<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>					<span style="color: #666666;">// Initialize</span>
	glutIdleFunc<span style="color: #008000;">&#40;</span>runWrapper<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> 	<span style="color: #666666;">// The program run loop</span>
	glutMainLoop<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>				<span style="color: #666666;">// Start the main GLUT thread</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>I&#8217;ve made a bit of progress, but when you think about it, static methods aren&#8217;t much different from the plain C functions.</p>
<p><strong>Problem 2</strong>: I want to have the functionality in the instance methods, yet I&#8217;m stuck with static methods. I&#8217;m not encapsulating the behavior inside instance methods, and I have no option for inheritance. I&#8217;ve still failed to hit the initial goal of creating an easy to use object oriented GLUT wrapper that&#8217;s extensible.</p>
<p><strong>Solution 2</strong>: I need to make virtual instance methods in the class and call them from the static callback functions. But I can&#8217;t make the function calls directly, I need a static instance of the class to make the instance function calls. (Re-read, as it&#8217;s a little complex) All I need to do is pass an instance of the class or subclass and I&#8217;ll be able to extend the functionality. It&#8217;s a little tricky/ugly, but it&#8217;s the best method I&#8217;ve found for encapsulating C style GLUT into a C++ application.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">class</span> AnimationFramework <span style="color: #008000;">&#123;</span>
<span style="color: #0000ff;">protected</span><span style="color: #008080;">:</span>
	<span style="color: #0000ff;">static</span> AnimationFramework <span style="color: #000040;">*</span>instance<span style="color: #008080;">;</span>
<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> displayWrapper<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> runWrapper<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> keyboardWrapper<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> keyboardUpWrapper<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> specialKeyboardWrapper<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> specialKeyboardUpWrapper<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">void</span> startFramework<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>argv<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">void</span> run<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">virtual</span> <span style="color: #0000ff;">void</span> display<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">float</span> dTime<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">virtual</span> <span style="color: #0000ff;">void</span> keyboard<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">virtual</span> <span style="color: #0000ff;">void</span> keyboardUp<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">virtual</span> <span style="color: #0000ff;">void</span> specialKeyboard<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">virtual</span> <span style="color: #0000ff;">void</span> specialKeyboardUp<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span></pre></div></div>

<p>The static methods are implemented here:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #666666;">// Static functions which are passed to Glut function callbacks</span>
&nbsp;
<span style="color: #0000ff;">void</span> AnimationFramework<span style="color: #008080;">::</span><span style="color: #007788;">displayWrapper</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	instance<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>displayFramework<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// calls display(float) with time delta</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">void</span> AnimationFramework<span style="color: #008080;">::</span><span style="color: #007788;">runWrapper</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	instance<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>run<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">void</span> AnimationFramework<span style="color: #008080;">::</span><span style="color: #007788;">keyboardWrapper</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	instance<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>keyboard<span style="color: #008000;">&#40;</span>key,x,y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">void</span> AnimationFramework<span style="color: #008080;">::</span><span style="color: #007788;">keyboardUpWrapper</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">unsigned</span> <span style="color: #0000ff;">char</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	instance<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>keyboardUp<span style="color: #008000;">&#40;</span>key,x,y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">void</span> AnimationFramework<span style="color: #008080;">::</span><span style="color: #007788;">specialKeyboardWrapper</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	instance<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>specialKeyboard<span style="color: #008000;">&#40;</span>key,x,y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">void</span> AnimationFramework<span style="color: #008080;">::</span><span style="color: #007788;">specialKeyboardUpWrapper</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> key, <span style="color: #0000ff;">int</span> x, <span style="color: #0000ff;">int</span> y<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	instance<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>specialKeyboardUp<span style="color: #008000;">&#40;</span>key,x,y<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>The startFramework() method is the same as provided in the Solution 1. </p>
<p><strong>EDIT:</strong><br />
I left out details on how the instance was set. In my program, I subclassed AnimationFramework and created classes for each program I needed overriding the appropriate methods. As an example, KeyFrameFramework was a subclass in my project.</p>
<p>I have a function in my AnimationFramework.h</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> setInstance<span style="color: #008000;">&#40;</span>AnimationFramework <span style="color: #000040;">*</span> framework<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>AnimationFramework.cpp</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">AnimationFramework <span style="color: #000040;">*</span>AnimationFramework<span style="color: #008080;">::</span><span style="color: #007788;">instance</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">void</span> AnimationFramework<span style="color: #008080;">::</span><span style="color: #007788;">setInstance</span><span style="color: #008000;">&#40;</span>AnimationFramework <span style="color: #000040;">*</span>framework<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	instance <span style="color: #000080;">=</span> framework<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>The main.cpp looks something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span>argv<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
&nbsp;
	AnimationFramework <span style="color: #000040;">*</span>f <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> KeyFrameFramework<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// Subclass of AnimationFramework</span>
	f<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setInstance<span style="color: #008000;">&#40;</span>f<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	f<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setTitle<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;Key Framing:&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	f<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setLookAt<span style="color: #008000;">&#40;</span><span style="color:#800080;">0.0</span>, <span style="color:#800080;">2.0</span>, <span style="color:#800080;">10.0</span>, <span style="color:#800080;">0.0</span>, <span style="color:#800080;">2.0</span>, <span style="color:#800080;">0.0</span>, <span style="color:#800080;">0.0</span>, <span style="color:#800080;">1.0</span>, <span style="color:#800080;">0.0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	f<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>startFramework<span style="color: #008000;">&#40;</span>argc, argv<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>I set the instance variable of the AnimationFramework class to an AnimationFramework subclass called KeyFrameFramework. Doing so allows me to use polymorphism and call the appropriate functionality that is specific to each animation project. Note: Don&#8217;t set the instance within a constructor, since the object is not fully initialized until the constructor is finished. You need to set the instance after your subclass object has been created.</p>
<p>Let me know if you have any questions. Below are the references I used.</p>
<p><strong>References:</strong></p>
<ul>
<li><a href="http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.5">http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.5</a></li>
<li><a href="http://www.parashift.com/c++-faq-lite/ctors.html">http://www.parashift.com/c++-faq-lite/ctors.html</a></li>
<li><a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=314567">http://www.gamedev.net/community/forums/topic.asp?topic_id=314567</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://paulsolt.com/2009/07/openglglut-classes-oop-and-problems/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Sorting Object Pointers in C++</title>
		<link>http://paulsolt.com/2009/01/stl-pointers-objects-and-sorting/</link>
		<comments>http://paulsolt.com/2009/01/stl-pointers-objects-and-sorting/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 01:48:09 +0000</pubDate>
		<dc:creator>Paul Solt</dc:creator>
				<category><![CDATA[Animation Project]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Boost]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[OpenGL]]></category>
		<category><![CDATA[STL]]></category>

		<guid isPermaLink="false">http://paulsolt.com/?p=90</guid>
		<description><![CDATA[<p>Today I was working on my computer animation project using C++, Boost, STL, and OpenGL. I ran into a few hitches related to pointers and the STL (Standard Template Library) and I decided to blog about it.</p> <p>Problem: You can&#8217;t override the default operator&#60;  for the pointer type, so you have to make a class/structure [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was working on my computer animation project using C++, Boost, STL, and OpenGL. I ran into a few hitches related to pointers and the STL (Standard Template Library) and I decided to blog about it.</p>
<p><strong>Problem:</strong> You can&#8217;t override the default operator&lt;  for the pointer type, so you have to make a class/structure that defines an operator() function, which is the function pointer. Any attempt to create a operator&lt; (const Frame *lhs, const Frame *rhs) will be ignored. You might find yourself wondering why objects are being sorted by memory address (pointer address), rather than your defined method. Here&#8217;s an excerpt from my code. (Thanks to <a href="http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/">CopySourceAsHTML</a>)</p>
<p>// Frame.h</p>
<div style="background: white none repeat scroll 0% 0%; font-family: Courier New; font-size: 10pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<p style="margin: 0px; padding-left: 30px;"><span style="color: green;">/** A compare class used for Frame pointers.*/</span></p>
<p style="margin: 0px; padding-left: 30px;"><span style="color: blue;">class</span> FrameComparer {</p>
<p style="margin: 0px; padding-left: 30px;"><span style="color: blue;">public</span>:</p>
<p style="margin: 0px; padding-left: 60px;"><span style="color: blue;">bool</span> <span style="color: blue;">operator</span>() ( <span style="color: blue;">const</span> Frame *lhs, <span style="color: blue;">const</span> Frame *rhs) {</p>
<p style="margin: 0px; padding-left: 90px;"><span style="color: blue;">return</span> (*lhs).getTime() &lt; (*rhs).getTime();</p>
<p style="margin: 0px; padding-left: 60px;">}</p>
<p style="margin: 0px; padding-left: 30px;">};</p>
</div>
<p style="padding-left: 30px;">
<p>&#8230;</p>
<p>//FrameViewer.cpp</p>
<div style="background: white none repeat scroll 0% 0%; font-family: Courier New; font-size: 10pt; color: black;">
<p style="margin: 0px; padding-left: 30px;"><span style="color: green;">/** Adds frames to be viewed at a later time */</span></p>
<p style="margin: 0px; padding-left: 30px;"><span style="color: blue;">void</span> FrameViewer::addFrames(std::vector&lt;Frame *&gt; frames) {</p>
<p style="margin: 0px; padding-left: 60px;"><span style="color: green;">// Append the new frames to current frames</span></p>
<p style="margin: 0px; padding-left: 60px;">_frames.insert(_frames.end(), frames.begin(), frames.end());</p>
<p style="margin: 0px; padding-left: 60px;">
<p style="margin: 0px; padding-left: 60px;"><span style="color: green;">// Sort</span></p>
<p style="margin: 0px; padding-left: 60px;">std::sort(_frames.begin(), _frames.end(), FrameComparer());</p>
<p style="margin: 0px; padding-left: 30px;">}</p>
</div>
<p><strong>Summary:</strong></p>
<p>I had a STL vector full of pointer objects, but the only way I was comparing was by pointer address until I created the FrameComparer class. With the class and an compare object defined I&#8217;m able to override the sort methods comparison behavior. This way will correctly sort the Frame objects by time value, rather than pointer address.</p>
<p><strong>References:</strong></p>
<p><a title="Function Pointers" href="http://www.cprogramming.com/tutorial/function-pointers.html">Function pointers</a></p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-2182421302031373";
/* Large Post Ad */
google_ad_slot = "4358587115";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://paulsolt.com/2009/01/stl-pointers-objects-and-sorting/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

