When compiling the VM for Xcode, one has to switch back and forth from the image to the command line. To make things easier, here’s a little script that:
- empties the build directory
- generates the sources and cmake info
- Configures with cmake
- Opens the project in Xcode
First, load PipeableOSProcess via:
(Smalltalk at: #ConfigurationOfOSProcess) load.
Then, execute this script (also available as a gist) whenever you want a fresh Xcode project:
PipeableOSProcess waitForCommand: '/usr/bin/osascript -e "tell application \"Xcode\" to quit"'.
buildDir := FileDirectory on: '/Developer/cogvm/cog/build/'.
buildDir entries do: [:e | e name = 'vmVersionInfo.h' ifFalse: [
ifTrue: [ e asFileDirectory recursiveDelete ]
ifFalse: [ e delete ] ] ].
addExternalPlugins: #( FT2Plugin );
PipeableOSProcess waitForCommand: 'cd /Developer/cogvm/cog/build/; /opt/local/bin/cmake -G Xcode'.
PipeableOSProcess waitForCommand: 'open /Developer/cogvm/cog/build/StackVM.xcodeproj'.
Apparently, gcc 4.2 is no longer installed with Xcode (as of Xcode 4.2). Unfortunately, older projects may need to be compiled with gcc. There is some scattered information online about how to get gcc 4.2 with Xcode 4.2, but they seem complex and error-prone (e.g. install Xcode 4.1, then upgrade to 4.2).
UPDATE: Here are some situations you might find yourself in:
- Upgrading from Snow Leopard to Lion – it seems that gcc et al will be moved to a different location. See here for a fix.
- Upgrading to Xcode 4.2 – gcc 4.2 should still be on your machine; you just have to tell Xcode 4.2 to list it as an option (in which case, skip to step #2 below)
- Installing Xcode 4.2 with no previous version – no gcc 4.2 at all; follow instructions below.
Here’s an easy way to get gcc 4.2 working :
1) Install gcc 4.2. via Mac Ports:
sudo port install apple-gcc42
2) Tweak Xcode so that gcc 4.2 appears as a compiler option, by editing the Xcode 4.2 GCC 4.2.xcspec file to get gcc 4.2 to show in the list of compiler options:
- Open the xcspec file for editing:
sudo vi "/Developer/Library/Xcode/PrivatePlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/GCC 4.2.xcplugin/Contents/Resources/GCC 4.2.xcspec"
- Change lines 41 and 42 from this:
ShowInCompilerSelectionPopup = NO;
IsNoLongerSupported = YES;
ShowInCompilerSelectionPopup = YES;
IsNoLongerSupported = NO;
- Link the gcc 4.2 binary to the location that Xcode expects
sudo ln -s /opt/local/bin/gcc-apple-4.2 /Developer/usr/bin/gcc-4.2
sudo ln -s /opt/local/bin/g++-apple-4.2 /Developer/usr/bin/g++-4.2
 Adapted from this Stack Overflow thread
The Tiobe index is total rubbish. But it’s worse than useless. It’s actually harmful. As Tyler Cowen mentioned in his TED Talk, “Be suspicious of stories”, feeling like you know what’s going on is way worse than admitting you don’t have a clue:
The most dangerous people are those that have been taught some financial literacy
Undoubtedly, there are people out there choosing careers and technologies based on the information age’s “divining by chicken bones”. Tiobe is based on search engine hits for goodness sake. In the uber-democratic-everyone’s-a-technical-blogger web, of what is “talking about a language” a good indicator? Here is a primary one: that the language and its tools are not sufficient to support development. In other words, the Niobe Index (i.e. search engine results) is inversely proportional to language quality, as seen below:
Since the equation above is obviously scientific (because it seems “mathy” and nerdy), it must be true. Furthermore (another great smart-people word), if one believes in (yes, like Santa Claus) the Niobe index (which can only be believed because it superficially seems scientific), one must believe my equation, which creates a paradox (another great science-y term).
In a live, open, dynamic environment (like Smalltalk*), the programmer has at their fingertips most of the things they would otherwise be forced to search the internet for, which is succinctly described by Torsten Bergmann. Also, working in a low level language, like C++ (e.g. manual memory management), guarantees search engine love. I used to need a Safari Books membership just to make sure I didn’t shoot myself in the foot.
* I am not pushing Smalltalk. In fact, I can’t wait until someone invents something better (hint, cough; VPRI).