Re: Stand Alone Executable for GFortran

Keith Marshall <[email protected]> Tue, 30 Jun 2020 23:23:48 +0100
Newsgroups gmane.comp.gnu.mingw.user
Organization MinGW.org Project
Message-ID <[email protected]>
On 30/06/2020 01:09, James McGroder wrote:
> On 6/29/20 1:44 PM, Pete Linden wrote:
>> I have two installs of Mingw and GFortran.  On the 1st one I can make
>> a Stand Alone Executable using GFortran. On the 2nd one, I can not
>> make a Stand Alone Executable for GFortran.
>>
>> Did I make an install error?
>>
> Hard to say... 

No, it's actually _impossible_ to answer this effectively, because the
original question is completely devoid of essential detail.  Pete, will
you please read, and inwardly digest in its entirety:
http://catb.org/~esr/faqs/smart-questions.html

> Please share gfortran & shell command line(s) for
> Stand-alone and and
> *NON* Stand-alone examples.

Yes, both of those are essential; also, we need to be told _exactly_
which packages, and their respective versions, comprise each of the two
installations in question.

> A Stand-Alone example could be something like this:
> 
> jim@OptiPlex-780 ~/src $gfortran hello.f
>  *** without -o option, a.out is default output
> jim@OptiPlex-780 ~/src $./a.out
> Hello World

And, as an example, even this is totally inadequate; where is the source
code, from which such an example might be compiled?  Furthermore, the
default output file is a.exe ... _not_ a.out, (which is a Unixism).

> On Non stand-alone, I'm inferring you mean something with subroutines...
> So how are they linked?

And again, source is imperative.

> Or are you working libraries?

Given how appallingly bad the original question is, I'm reluctant to
offer _any_ sort of answer, but as a wild, and entirely speculative
guess, I'd incline toward this; default linking mode for gfortran pulls
in libgfortran-5.dll, together with libgcc_s_dw2-1.dll, both of which
must thus be distributed along with any dependent application, so
rendering that application non-stand-alone:

  $ cat foo.f
        program hello
          print *, "Hello World!"
          end

  $ mingw32-gfortran foo.f
  $ mingw32-ldd a.exe
  a.exe
   +- KERNEL32.dll
   +- msvcrt.dll
   +- msvcrt.dll
   +- libgcc_s_dw2-1.dll
   |   +- KERNEL32.dll
   |   +- msvcrt.dll
   +- libgfortran-5.dll

Note that the above was cross-compiled, on my GNU/Linux box, hence the
"mingw32-" prefix to commands; the dependency on libgfortran-5.dll is
clearly evident, as is a further dependency on libgcc_s_dw2-1.dll

If my wild guess is correct, and this is the OP's issue, then both of
those dependencies may be eliminated, by compiling with "-static":

  $ mingw32-gfortran -static foo.f
  $ mingw32-ldd a.exe
  a.exe
   +- ADVAPI32.DLL
   +- KERNEL32.dll
   +- msvcrt.dll
   +- msvcrt.dll

The remaining dependencies are all standard MS-Windows system DLLs, so
in this case, a.exe becomes effectively self-contained.

If my wild guess is incorrect, then I'm sorry, but no one can offer a
better answer until the question is asked more appropriately.

-- 
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F

_______________________________________________
MinGW-Users mailing list
[email protected]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.osdn.me/mailman/listinfo/mingw-users
Also: mailto:[email protected]?subject=unsubscribe
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEwZ7AGBVH3lDh1I9TwK02xjR+Wj8FAl77u3QACgkQwK02xjR+
Wj/i3w/8Di8h7jZokLnd3AK/rpV53HcoPckvwXqbTFnUbqrIsmbCq6tFB62VgKON
9rN2bIOGmXXIFCgEhPO73ObLh25gbnhybUkpRe+F2GJpzUrx+rj5081vvlDytKc6
XHoXm5xWycIQScAZ60QjXj9aY9dwuEWZ7PqeJD3QOMB/wpqRReA5UcL4RUH0pua6
JKI58m2xYLd7lzlLzEI6AJAQKiTGHGm8Msn0bmIDSv2p49KxblmNtqdJfTItWk6x
sk+9Qb5mWDuX+cvXqMAbEedKHz1mGLxJVpvP+7o7VgFdCkdW767S1qFToRnMKgzl
oJSom/M5gO5t/0QnEBjE6MQvWQbOpbtenwJ+VfGT8dVx7h1yVPohjM4Oe1zDDCDe
m3JhDPU/g1bnauxhVoSYK4UYcR/Q+kruTMbJIvM2BhfZ/dVlUin3HzNPGNOy4O7m
fbrKHjp0sLCJDd0QaKtlFW2KO11xo5TdGQzD8pIbnsOULEs7VJe4s/Arl3Ks9qTi
4r5gClu+sw017166yOiLo2nz+kVd9FEIxQPcFxRrzjkknMS+6SHQLTcyNEKONvRU
M0e0jK82or35VlRhMsRxhLbFMKhXMfZM1NEDrgCaB0ZDuTuRH8Ij4SMwGuUZBVVh
6dhxj5E7xWu4QZHvm8Thv9HuEYoByx6JMnbJCcRfL/W0YQaD55g=
=aTGh
-----END PGP SIGNATURE-----