NOTE: This plugin will not work with Xcode 2.5 or 3.0. And will not work in Leopard at all. The plugin will work on Mac OS X Tiger with Xcode 2.4.
UPDATE UPDATE UPATE UPDATE UPDATE UPDATE UPDATE
A newer version of the plugin, installer and gfortran is now available. Please see the following news item:
About a month or so ago, we put out a call for someone to develop a gfortran plugin for Xcode. Damien Bobillot has stepped up to the plate and produced a plugin that meets the requirements of the contest. As a result of his winning entry, Damien will receive a 4GB iPod Nano. You can download all of the files necessary to begin using the plugin directly from the MacResearch site (see below). Detailed instructions for using the plugin, as well as possible remedies for troubleshooting are given below.
One of the requirements for the contest was that the plugin source be made publicly available. It is our hope that others will take advantage of Damien’s good work to help extend and improve the plugin and make the changes available to the community at large. If you do modify the plugin, please keep in mind that crediting author is Damien Bobillot, and please let us know that an update is available. If there is enough development interest, MacResearch can host a repository on the project.
Thanks again Damien for your work on this and enjoy the prize!
NOTE: The current plugin does not produce Universal Binaries
NOTE: The binaries for gfortran provided here are from hpc.sourceforge.net and may install in a directory different from the most current version on that site (currently the version here is the August 2006 build). They are provided here as a convenience to get the plugin to work in a standard configuration. The credit for creating these binaries belongs to Gaurav Khanna. Thanks to Gaurav for allowing us to mirror the current distribution here.
Table of Contents
gfortran compiler instructions
You must use either the August 2006 version of gfortran from Gaurav’s site OR the version supplied here. It must be installed using the method described below. If you have a newer version of gfortran installed, please see the note at the end of the document on how to modify the source to create an updated plugin. The plugin has been tested in Xcode 2.4.
1) Download the gFortran compiler appropriate for your system.
2) Unpack the archive using the following command.
(PPC): sudo tar -zxvf gfortran-ppc-bin.tar.gz -C /
(Intel): sudo tar -zxvf gfortran-intel-bin.tar.gz -C /
Note: If your browser tried to unpack the archive and you have a tar archive instead of a .tar.gz file issue the one of the following commands instead:
(PPC): sudo tar -xvf gfortran-ppc-bin.tar -C /
(Intel): sudo tar -xvf gfortran-intel-bin.tar -C /
Install the gfortran plugin and templates
1) Download the package installer for the gfortran plugins and templates
2) Unzip that archive and run the installer.
The installer will install a fortran file template in:
/Library/Application Support/Apple/Developer Tools/File Templates
and it will install the plugin into:
Using the plugin
1) Start up Xcode 2.4
2) Create a new project File > New Project > Command Line Utility > Standard Tool
3) Name the project “fortran”
4) Right click on the Source folder and select Add > New File…
5) Scroll down to the Gfortran option and select “Gfortran” as the file type
6) If you like rename the file (for this example it will stay untitled.f)
7) Edit the file as in the following image
8) Click on the top level project icon and then click on the “Get Info” button
9) For Architectures make sure only ppc is present (if on Intel set it to i386)
10) Expand the Targets group in the main project window, select the target (called “fortran” if you named the project as in step 2) and click “Get Info”. IMPORTANT: Make sure ONLY pcc OR i386 is present (as in step 9).
11) Edit main.c as in the image below (note the trailing underscore after the call to the test function)
12) Set the build type to Release. Click on Build and Go. You should see something similar to the image below
1) This plugin does not yet produce Universal Binaries. The source code is provided for anyone who wishes to extend the application.
2) If you get a link time error (especially in Debug mode on PPC based systems) you may need to add the gfortran libraries to the project directly. Do the following:
a) With your project still open, open a new terminal window and type:
b) Drag libgfortran.a to the project pane (place it anywhere, but under the “Source” group is convenient.
c) Try building the application again.
If the above fails, try switching your build settings to Release instead of Debug.
Important note: Regarding Debug vs. Release. Depending on the system type PPC or Intel you are using, the Debug mode may require that you always include the gfortran library as part of the build process (this is because ZeroLink currently doesn’t work, at least for the PPC version of the plugin). However, you may find that when you switch to Release builds, the program gives a warning about a missing dylib at runtime. In that case, remove the explicit gfortran library from the project and rebuild the application. It should then run as normal. Alternatively, just compile in release mode all of the time.
There are a number of places that the fortran compiler settings are set. You can view these in the source code in the following files:
fortran.pbcompspec (ExecPath variable)
BDCompilerSpecificationGFortran.m (~lines 55-60)
Changing those settings should allow you to use another build of gfortran (or gfortran installed in an alternate location).
Leave a Reply