Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code info within the executable with gfortran 1

Status
Not open for further replies.

GerritGroot

Technical User
Nov 3, 2006
291
ES
Hi,

Building (and compiling) an executable in gfortran using the options:
-Wall
-O3
-fbounds-check

It happened to me that the executable seemed to have fortran code information included, which is not always desired.

Once running the executable, the program broke down on some insignificant error and said something like:
Code:
"error on line so and so of subroutine so and so"

My question is:

Why does my executable contain this information, shouldn't it be just plain machine code not knowing anything about the source code?

Can I exclude this info from my *.exe by some compiler option?

Thanks,

Gerrit


P.S.: Can't repeat the message here because I improved the code already and don't remember exactly where it was.
 
Try adding -s to your compile line. On gcc, it removes all symbolic information. You can check afterwards with nm or strings on the binary. These are std *nix commands. I suppose the equivalent in windows is something like notepad.
 
Thanks xwb, I added the -s option to all compile lines, but unfortunately it had no effect.

If I open the *.exe in for example textpad, I can still see all symbolic information. (The file didn't get less kB either, so it contains the same apparently)
 
Don't know if this is available on windows. On Linux you use strip to remove the symbols. On windows it comes with g95 but I don't know about gfortran.
 
Strip? Do you mean an option like -strip? Gfortran says it does not recognize that.

Or should I add it somehow while building the executable from the compiled object files??

BTW: -s gave a slight reduction after having removed -fbounds-check, but still not a complete stripped *.exe
 
-s works on linux. Not sure what the difference is. I'll have to download a gfortran compiler on my windows box and try it out. Maybe not all flags have been implemented on the windows port.
 
Can't seem to get gfortran on windows to work. The mingw version has a dependency on cygwin and I don't really wish to install cygwin. g95 had this problem a while back. Anyway, amongst the binaries, there is a program called strip.exe.
 
I got your point. As for the windows installer, strip.exe comes with gfortran and...
Code:
strip.exe --strip-all MyFatExe.exe -o MySlenderExe.exe

did PART of the trick, a big part though!

The file size reduced from about 800kB to approximately 200kB, BUT not everything has been stripped, I can still see routine or module names with complete routes like "./MyModules/MyFirstModule.f90" within the executable viewing it like hex.

Nevertheless, a small step for mankind but a giant leap for a man already.

Any advice on cutting away the last bit of junk from my *.exe is very welcome
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top