Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

distributing gfortran executables

253 views
Skip to first unread message

tho...@antispam.ham

unread,
May 18, 2013, 6:02:44 PM5/18/13
to
I wanted to give someone an executable file generated with gfortran.
Knowing that he has a 32-bit Windows Vista machine without gfortran
installed, I used a 32-bit Windows XP computer and the command line
option -static-libgfortran during compilation to produce an executable
file for him, but it didn't work. His computer complained about
needing libgcc_s_dw2-1.dll, as did a 64-bit Windows 7 computer of my
own on which I have 64-bit gfortran 4.7.1 installed, but the program
worked after I copied that DLL from my 32-bit Windows XP laptop to my
64-bit Windows 7 laptop.

Turns out that the 32-bit executable was built using an experimental
version of 4.8.0 (I haven't installed the released version yet). Is
the need to distribute a DLL with executables something new in version
4.8.0, or is it considered a bug that -static-libgfortran didn't link
in the necessary code from this DLL, or am I misunderstanding the use
of the -static-libgfortran option? I seem to recall trying simply
-static many months ago when I needed to send an executable to someone
else, and that didn't work, but -static-libgfortran did work.

Tim Prince

unread,
May 19, 2013, 1:32:08 PM5/19/13
to
It looks like -static-libgfortran is transferring the dependence on gcc
support library from libgfortran.dll to the .exe, and that this gfortran
has a dependency on seh. I don't think my installation is the same as
yours, and I don't care to find out what yours is and make a change.
If the developers have been able to find a solution to these exception
handling problems which seemed to prevent updating Windows gfortran, I'm
not going to carp about relative uselessness of -static-libgfortran.
--
Tim Prince

baf

unread,
May 21, 2013, 11:58:31 AM5/21/13
to
Strange. I have been using the -static option for some time without
problems on windows machines. What version of gfortran did you use to
create the executable?


tho...@antispam.ham

unread,
May 21, 2013, 8:24:43 PM5/21/13
to
baf <b...@nowhere.com> writes:

> Strange. I have been using the -static option for some time without
> problems on windows machines. What version of gfortran did you use to
> create the executable?

I tried two different versions of gfortran. Because the target was
32-bit Windows Vista, my first attempt was on a 32-bit Windows XP host
running an experimental build of 4.8.0. Later, after I finally found
the right command line option (-m32), my second attempt was on a 64-bit
Windows 7 host running 4.7.1. In both cases, the command line option
that I used to link in the libraries was -static-libgfortran. In both
cases, the executables did not work on the 32-bit Windows Vista machine,
but the DLL it wanted was different.

Since then, I've done some experimentation. I built four executables
of a program on the 64-bit Windows 7 host:

1: no static options at all
2: -static
3: -static-libgfortran
4: -static and -static-libgfortran

Interestingly, executables 2 and 4 were the exact same size, but
differed in exactly two bytes. Both worked on the 32-bit Windows Vista
machine without any libraries. Executable 1 did not work, as expected,
and executable 3 also didn't work. The main reason for building
executable 1 was so that I could compare file sizes. I also looked at
the file sizes for the corresponding DLLs. As expected, the size of
executable 3 increased compared to executable 1 by almost the size of
the libgfortran DLL, and the sizes of executables 2 and 4 increased
compared to executable 3 by almost the size of the gcc DLL.

So the problem was due to a misunderstanding on my part of the
difference between the -static and -static-libgfortran options.
I had an experience a long time ago in which my memory was that
-static-libgfortran worked, while -static did not, so either my
memory of that event is faulty, or the experiment was corrupted
by the presence of a DLL that I didn't know about, or maybe the
compilers have changed since then. Whatever the case, I now know
that -static is all one needs to generate a standalone executable.

But this experience does raise an interesting question: under what
circumstances would someone want to use -static-libgfortran?

Also, it seems to me that having a single web page that provides
ALL the command line options for gfortran would be useful, rather
than the current practice of having the gfortran-specific options
separate from the gcc-generic options. They could be kept segregated
on the same web page, with clear indications as to which are generic
to the gcc compiler suite and which are specific to gfortran. But
it would simplify searching for the option you need. It took me too
long to find the -m32 option that I needed to generate a 32-bit
executable for the target system on a 64-bit host.

0 new messages