Fortran Is an IDE Necessary for Debugging Fortran Code?

  • Thread starter Thread starter Saladsamurai
  • Start date Start date
  • Tags Tags
    Eclipse Fortran
Click For Summary
The discussion centers on troubleshooting issues with building a Fortran project in Eclipse after switching from C++. The user experiences difficulties related to the Makefile, which is empty, and questions its necessity, noting that modern languages often do not require explicit Makefiles. The conversation reveals that the user has gfortran installed but faces a PATH environment issue, preventing Eclipse from locating the compiler. Suggestions include running Eclipse from the terminal to inherit the correct PATH and ensuring the correct directory is set for building the project. The thread highlights the importance of correctly configuring the development environment for successful compilation and debugging of Fortran code.
  • #31
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:
 
Technology news on Phys.org
  • #32
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.
 
  • #33
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):

Screenshot2011-12-29at53706PM.png
 
  • #34
Do you see the document "HelloWorld2" in the Debug folder?
Try right-clicking that...
 
  • #35
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
Screenshot2011-12-29at55512PM.png


which brings me to the following screen:

Screenshot2011-12-29at55536PM.png


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.
 
  • #36
Perhaps you could select HelloWorld2 Debug in the project explorer in the left window?

And then perhaps click the button Run?
 
  • #37
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.

Screenshot2011-12-29at61459PM.png
 
  • #38
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...
 
  • #39
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.
 
  • #40
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.
 
  • #41
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!
 
  • #42
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.
 
  • #43
This is what I have done:
.
.
.
1) Launch Eclipse and Open a 'Fortran Perspective'

Screenshot2011-12-29at73441PM-1.png

.
.
.
2) Create New Fortran Project:

Screenshot2011-12-29at73531PM.png

.
.
.
3) Add Source Folder and File

Screenshot2011-12-29at73726PM.png

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

Screenshot2011-12-29at73926PM.png


...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:

Screenshot2011-12-29at75301PM.png


.
.
.
.
.
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 ?
 
  • #44
"Run As / Local Fortran Application" should be fine.
 
  • #45
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)

Screenshot2011-12-29at80309PM.png
 
  • #46
Can you right-click the binary HelloWorldProject and select Run configurations?
 
  • #47
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:

Screenshot2011-12-29at81206PM.png


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?
 
  • #48
Yep. That's it.
 
  • #49
Ok :smile: When I click on 'Fortran Local Application' and then click the 'New' button I am presented with the following screen:

Screenshot2011-12-29at81725PM.png


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

Screenshot2011-12-29at81931PM.png


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?
 
  • #50
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.
 
  • #51
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.
 
  • #52
Yeah, do Apply first and then Run.

What is the path to your binary?
Does it contain a space?
 
  • #53
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:
 
  • #54
Cheers! :smile:
 
  • #55
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!
 
  • #56
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!
 
  • #57
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?
 
  • #58
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...
 
  • #59
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.
 
  • #60
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.
 

Similar threads

  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 59 ·
2
Replies
59
Views
11K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 29 ·
Replies
29
Views
6K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K