Is an IDE Necessary for Debugging Fortran Code?

  • Topic: Fortran 
  • Thread starter Saladsamurai
  • Start date
  • Tags Tags
    Eclipse Fortran
61 replies · 24K views · last reply
I like Serena said:
It appears you tried to build HelloWorldProjectInC++, but that is not in fortran.

Furthermore Eclipse knows there is nothing to do.
Right-click on your project and select "Clean".
Then right-click on your project again and select "Build".
This will force Eclipse to rebuild.

Yes, the Debug directory would be where the executable is.
Apparently it does run there.
It seems it does not print anything, otherwise you would have seen this in the output...

OMG. I am really starting to dislike Eclipse. Why would it build 'HelloWorldProjectInC++' when my active window is the source code in my Fortran project? Anywho: After Clean/Build, this is what I get:

Code:
**** Build of configuration Debug for project HelloWorld2 ****

make all 
Building file: ../HelloWorld2SourceFolder/HelloWorld2.for
Invoking: GNU Fortran Compiler
gfortran -funderscoring -O0 -g -Wall -c -fmessage-length=0 -o "HelloWorld2SourceFolder/HelloWorld2.o" "../HelloWorld2SourceFolder/HelloWorld2.for"
Finished building: ../HelloWorld2SourceFolder/HelloWorld2.for
 
Building target: HelloWorld2
Invoking: MacOS X Fortran Linker
gfortran  -o "HelloWorld2"  ./HelloWorld2SourceFolder/HelloWorld2.o   
Finished building target: HelloWorld2
 

**** Build Finished ****

I still get the Binary Not Found error when I try to run it. :cry:
 
Check the project explorer window in Eclipse (the left window).
In the Debug directory you should be able to find the binary HelloWorld2.
Right-click it and select Run.

If you can't find it, right-click Debug and select Refresh first.
 
I like Serena said:
Check the project explorer window in Eclipse (the left window).
In the Debug directory you should be able to find the binary HelloWorld2.
Right-click it and select Run.

If you can't find it, right-click Debug and select Refresh first.

I don't seem to have any Binaries (And hence the Error). This is all I have (refreshing does not improve):

Eclipse Fortran Projects tree view for project HelloWorld2 with Includes, HelloWorld2SourceFolder containing HelloWorld2.for and HelloWorld2 executable, and Debug folder holding HelloWorld2.o, subdir.mk, makefile, objects.mk, sources.mk.
 
Do you see the document "HelloWorld2" in the Debug folder?
Try right-clicking that...
 
I like Serena said:
Do you see the document "HelloWorld2" in the Debug folder?
Try right-clicking that...

Jeesh. I right click that and I can choose 'Run As' -> Run Configurations
Eclipse IDE screenshot showing a Fortran Projects tree with HelloWorld2, a context menu open with Run As > Run Configurations highlighted, and the HelloWorld2.for source and CDT build console beside it.


which brings me to the following screen:

Eclipse Run Configurations dialog with the left tree listing C/C++ Application entry HelloWorldProjectInC++ and Fortran Local Application entry HelloWorld2 Debug, and the Main tab showing C/C++ Application Debug/HelloWorldProjectInC++ and Project HelloWorldProjectInC++.


I am not sure where to go from here. Everything is prefilled with the C++ project stuff. I don't understand why. I am clearly right clicking on the HelloWOrld2 bin which is in the fortran project.
 
Perhaps you could select HelloWorld2 Debug in the project explorer in the left window?

And then perhaps click the button Run?
 
I like Serena said:
Perhaps you could select HelloWorld2 Debug in the project explorer in the left window?

And then perhaps click the button Run?

I erased the C++ project so Eclipse doesn't get confused. I highlighted the debug folder and this is what I get when I click run. Notice the rather empty build message in the console again. This is pretty awful. If Eclipse is this difficult to get Hello World running, I cannot imagine getting any real work done on it. Thanks again for all your help. Feel free to call it a day whenever you need to. Getting Fortran to run on a Mac is the stuff of legend and I am now seeing why.

Screenshot of the Eclipse Fortran IDE showing a Problem Occurred dialog: Launching HelloWorld2 Debug has encountered a problem. A program file was not specified in the launch configuration.
 
Perhaps you can show the Run Configurations screen that you used?

It appears that the first edit field (where you had C/C++ Application before) was not filled properly...
 
I like Serena said:
Perhaps you can show the Run Configurations screen that you used?

It appears that the first edit field (where you had C/C++ Application before) was not filled properly...

I did not set up a run config this time. I just clicked the 'play' button.
 
Ah, I'm afraid the Play button only works after the first time that you've succesfully run the application.
It's a sort of most-recently-run menu option.

The first time round it won't do anything useful.
 
I like Serena said:
Ah, I'm afraid the Play button only works after the first time that you've succesfully run the application.
It's a sort of most-recently-run menu option.

The first time round it won't do anything useful.

Hmmm. Ok. Now that I have removed the C++ project, the context sensitive options I am given are a little different. There is a Rin Config option now. I am going to delete the workspace folder and the current projects and start fresh. I will post exact step-by-step screenshots of what I do.

Thanks again boss!
 
If it's not too late already, try to avoid directories with spaces in them!
Command line tools (such as used in Eclipse) are notoriously bad with those and can respond unpredictably.
 
This is what I have done:
.
.
.
1) Launch Eclipse and Open a 'Fortran Perspective'

Screenshot of the Eclipse IDE in its Fortran perspective, showing an empty Fortran Projects pane, a blank editor area, an Outline pane reading 'An outline is not available', and an empty Problems panel listing 0 items.

.
.
.
2) Create New Fortran Project:

Eclipse dialog titled Fortran Project showing project name HelloWorldProject, project type list with Executable (Gnu Fortran on MacOS X) selected, and GCC Fortran toolchain selected.

.
.
.
3) Add Source Folder and File

Eclipse IDE New Fortran Source File dialog with source folder HelloWorldProject/HelloWorldSource and source file HelloWorld.for, template set to Default fixed-form Fortran source file template.

.
.
.
4)Write Source Code and Build Project...

Screenshot of the Eclipse IDE with a Fortran project open, showing the source file HelloWorld.for containing a short program that prints Hello World, and the build console output below.


...Resulting in Following Console output:

Code:
**** Build of configuration Debug for project HelloWorldProject ****

make all 
Building file: ../HelloWorldSource/HelloWorld.for
Invoking: GNU Fortran Compiler
gfortran -funderscoring -O0 -g -Wall -c -fmessage-length=0 -o "HelloWorldSource/HelloWorld.o" "../HelloWorldSource/HelloWorld.for"
Finished building: ../HelloWorldSource/HelloWorld.for
 
Building target: HelloWorldProject
Invoking: MacOS X Fortran Linker
gfortran  -o "HelloWorldProject"  ./HelloWorldSource/HelloWorld.o   
Finished building target: HelloWorldProject
 

**** Build Finished ****
.
.
.
5) On Toolbar go to: 'Run' and I am presented with the following options:

Screenshot of the Eclipse Run menu open over a Fortran project, with the Run As submenu showing options 1 Local C/C++ Application and 2 Local Fortran Application.


.
.
.
.
.
I am tempted to say that I should just be able to go to 'Local Fortran Application' and run it. Do I need to actually go into the 'Run Configurations...' menu ?
 
I like Serena said:
"Run As / Local Fortran Application" should be fine.

Should be but is not. I get the Launch Failed: Binary Not Found error again:
.
.
.

6)

Screenshot of the Eclipse Fortran IDE showing the HelloWorld.for source file with a three-line program, and the CDT build console reporting a successful build of HelloWorldProject.
 
Can you right-click the binary HelloWorldProject and select Run configurations?
 
I like Serena said:
Can you right-click the binary HelloWorldProject and select Run configurations?

When I Right-Click the Binary and select Run As -> Run Configurations I am presented with the following screen:

Eclipse Run Configurations dialog listing launch types such as C/C++ Application, Fortran Local Application, Java Applet and Parallel Application, with a filter box and help text for New, Duplicate, Delete and Filter buttons.


I am not sure what to do next? I am thinking click on 'Fortran Local Application' and then click the 'New' button. What do you think?
 
Ok :smile: When I click on 'Fortran Local Application' and then click the 'New' button I am presented with the following screen:

Eclipse Run Configurations dialog for a Fortran Local Application named HelloWorldProject Debug, with the Fortran Application field empty and the error 'Program not specified'.


It looks like Eclipse wants me to specify the Binary? If I click: 'Search Project...' I am presented with:

Eclipse Program Selection dialog over the Run Configurations window, with an empty 'Choose a program to run' field, empty Binaries and Qualifier lists, and Cancel and OK buttons; the background shows 'Program not specified' error.


Does this mean Eclipse is not 'seeing' the binary (maybe this explains error message)?

Maybe I should try to 'Browse' all the way to the Binary?
 
Yep. Try Browse all the way to the binary.

Btw, Search project should work, but we'll see... just keep an eye out for weird stuff.
 
I like Serena said:
Yep. Try Browse all the way to the binary.
Ok. Should I 'Apply' or 'Run' ? I am thinking Apply, then Run if necessary.

Btw, Search project should work, but we'll see... just keep an eye out for weird stuff.

Yeah. Search Project definitely not working. You can see that the window it gave me is empty.
 
Yeah, do Apply first and then Run.

What is the path to your binary?
Does it contain a space?
 
I like Serena said:
Yeah, do Apply first and then Run.

I can't believe that this worked! All that work for a simple Hello World.

What is the path to your binary?
Does it contain a space?

Code:
/Users/saladsamurai/Documents/workspace_PTP/HelloWorldProject/Debug/HelloWorldProject

No spaces.

Now I am wondering what I will need to do every time I create a new project. I will create a HelloWorld2 project to see what Eclipse "remembers" and what it forgets.

Thanks SO MUCH for all of your effort ILS! Next time you're in the US I'll buy you a coffee :smile:
 
I like Serena said:
Cheers! :smile:

Now for the hard part: Getting C++ and Java to work in the same IDE! I am pretty sure C++ is ready to go. But I had some trouble with Java... I'll mess around a bunch and post back with my findings!
 
Or, you could save yourself a lot of grief by

1. Learn how to use "make"
2. Learn how to configure your favorite text editor to run "make" with a single keystroke
3. Never use an IDE again ...

Everybody who writes an IDE seems to have their own ideas about what is "easy and intuitive". And none of them ever match MY ideas about what is easy and intuitive!
 
AlephZero said:
Or, you could save yourself a lot of grief by

1. Learn how to use "make"
2. Learn how to configure your favorite text editor to run "make" with a single keystroke
3. Never use an IDE again ...

Everybody who writes an IDE seems to have their own ideas about what is "easy and intuitive". And none of them ever match MY ideas about what is easy and intuitive!

Indeed! How do you debug without an IDE?
 
It appears that I have to navigate to the path manually every time and set up run configurations. I am still convinced that when I click on 'search project' Eclipse should be 'seeing' the binary it just created, but as in Post #49 in the 2nd screenshot, it is not seeing it.

When I click 'Search Project' could it be looking on the wrong path? I am assuming that Eclipse must be looking on what is referred to as the "Build Path." There must be a way to check what it thinks the Build path is...
 
Eclipse keeps a cache in which it remembers what it has built.

When you build an executable using the terminal window, you typically get this problem that Eclipse doesn't "see" the executable with "Search project".

The way I know to recover from that, is to let Eclipse rebuild everything (Ctrl+B).Anyhow, after the first time you adjusted the run configuration, Eclipse will remember the location of the executable.
 
Saladsamurai said:
Indeed! How do you debug without an IDE?

An IDE doesn't debug your code for you.

You debug code by thinking. and playing with an IDE is often a distraction from that.

Of course you need a debugger to tell you the basic information like where your code crashed. But 99% of the time you can get all the information you need from a core dump and a stack trace, wthout the pretty graphics.