Xcode 4 and fortran

Xcode 4 and fortran

Hi folks,

I guess most people will tell me 'Xocde 4 is not supported' but I know some other people have had (at least partial) success building fortran applications in Xcode 4. Now I have the opportunity to give it a go in a friend's computer to see if it is worth for me buying iy. although it is cheap, I'm modtly developping in fortran so I wouldn't be using it for anything else if i can't make it work taht way...

So my question is simple: yesterday I spent a bit of time trying to figure out how to configure Xcode 4 to build and debug fortran files, to no avail. It looks so much more complicated than Xcode 3.2.6 that I am at lost...
Does anybody know how to do that configuration? if so, could you please explain that a bit or point me to a short tutorial?

Thanks a lot,

Ferran.

11 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

Hi!
So first of all you must have Xcode 4,the intel compiler with Xcode integration installed.
Launch Xcode-->create new Xcode project--> Mac OS X Application,Command Line Tool-->Name for the project(C type)--> select the locaion for the project--> Create.
Delete the main.c file that has been created by default and select File-->New--> New file-->Other-->Empty--> Name the file with a fortran extension(for example Main.f90).
Write something(hello world program), then select Product--> Build(or press cmd+B), it should build fine,then select Product --> Run(or press cmd+R) to maka it run.

Cheers!

Luca

Hi Luca,

first of all, thanks for the reply :)
Now going to your recipe: I thinks that is exactly what I tried, but that didn't work well. it compiled fine and I could run it, but *nothing* came up in the integrated terminal, when it was supposed to print a sentence and wait for me to enter some numbers... Then trying to build it for debugging lead to lots of errors at compilation. On the otehr hand I know the program was right and I couldcompile it/debug it in an ourtside, regular OSX terminal.
Then I translated the code to C and everything went Ok compilation and debugging.
So what i thought is that I'm not specifying anywhere what fortran compiler to use. Are you specifying that anywhere? That didn't appear in your procedure...

Thanks a lot,

Ferran.

Hi!

Nope, I didn't have to configure anything,it worked right out-of-the box.
When you create the fortran file and build it are you getting the notification "Build Succeeded"?
After that go to View-->Navigator-->Log(or press directly cmd+7),you should see the history of the actions for the project,click on the build that you just did:if you have just one file there should be two steps only(one for compiling the file and the other for the linking stage,maybe you have to choose also to show "All messages"),if you click on one step a button appear at the far left that expands the step showing what it does:check if it is invoking ifort.Here is a screenshot of what it should be like:http://img801.imageshack.us/i/screenshotzn.png/(I don't know how top ost a picture in this forum).
Another stuff you can check is by pressing cmd+1(this will bring back the left panel to show the source etc),click the xcodeprojectfile(the bue file), then your target and choose build rules and see if you have the build rules for the fortran file(should point to the ifort compiler).

Cheers!

Luca

Hi Luca,
thanks once again for your help. Now i'm working but this afternoon i'll try to give this one a go. I certainly didn't build myself a rule to tell Xcode to point to the ifort compiler, so God only knows what was Xcode doing actually. i certainly did see the 'Build successful' message at compilation time, but as I said, trying to execute it lead nowhere... nothing came up on the terminal.
But I'll check that one and report back here :)
Thanks again,
Ferran.

Hi again pal,still having trouble with that stuff... In my case, although I have Intel fortran Compiler 12.0 installed in my systtem, Xcode4 doesn't ind it by default. So i do as you say about the Buid Rules, and there I see my target has not been identified as a fortran program. Then what i do is Add a New Rule -> Process -> Fortran source files ,Using -> I find nothing like ifort or any fortran compiler as gfortran or g95 either (I have them all installed).Ehat should i do then? Set Using -> Custom Script ? Then what do i write in the script, and in the output file panels? What is your current configuration?Thanks again and again,Ferran.

Hi!
As I said I didn't have to do anything: the rule for the Fortran source file was already there and enabled.
Maybe something went wrong in the installation process of the FortranCompiler?
Checking the integration with Xcode in the installation process creates at least these files(there may be others but I didn't find them yet), assuming that you have the all the defaults folder(/Developer for Xcode and /opt/intel for ifort):
1) /Developer/opt --> These folder seems to be just a copy of the folder created in /opt/intel
2) /Developer/usr/bin --> In this folder you should find symlinks of some executables(ifort and idb for example)
3) /Developer/Library/Xcode/Third-Party Plugins --> Here you should find the ifort compiler plugin

Do you have these files?

Cheers!

Luca

Hi Luca,yes 1) and 2) but not 3)... I have reinstalled ifort this afternoon but that 3) you mention is not there. And I installed ifort 12.0 including Xcode support. But i don't have this Third-party Plugins. What do you have there exactly?
What intel compiler version / Xcode version do you have installed?
Cheers,
Ferran.

Hi!

That's odd, here is what I've got in that folder:http://img10.imageshack.us/i/screenshot20110409at629.png/
Note the full-path of the folder(I-ve also the icc plugin in this case), maybe you can try searching inside the /Developer/Library/Xcode if there are in another folder.
I've got the latest of both Xcode(4.0.1 but it worked also with 4.0) and ifort(version 12 update 3 but it worked also with update 2)

Last login: Sat Apr  9 17:53:07 on ttys000
MacBook-Pro:~ Luca$ gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

MacBook-Pro:~ Luca$ ifort --version
ifort (IFORT) 12.0.3 20110309
Copyright (C) 1985-2011 Intel Corporation.  All rights reserved.

Cheers!

Luca

You need to set the Intel compiler to compile Fortran files. The included documentation describes how to do this...for Xcode 3.For Xcode 4, the process is similar, but some stuff has moved around:

To select the Intel
Fortran Compiler:

  1. Select the target you want to change and click Build Rules.

  2. Add a new rule by clicking Add Build Rule in the
    lower-right corner of the project editor.

  3. Under Process, choose Fortran source
    files
    .
  4. Under Using, select the Intel (Fortran) compiler.

Does that help?

Dear all,

I have mac OS X 10.7. I installed Xcode 4.6 and command tools. I wanted to run some fortran codes, so I installed evaluation version of intel compiler. But the error reports are now more than before and now I can't even compile and run "hello world"!

This is the error report: "Command /usr/bin/ifort-13.0 failed with exit code 71"

I tried to uninstall intel compiler and xcode to return xcode to its former situation, but It was not possible! I delete all components of intel compiler but I know it still exists! because in xcode still there is the option of creating new fortran file.

Please help me I'm stucked.

Connectez-vous pour laisser un commentaire.