[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mingw-users
Subject:    [Mingw-users] static and dynamic linking with mingw32 fortran and
From:       Jonathan Marsden <jmarsden () fastmail ! fm>
Date:       2009-09-23 4:39:40
Message-ID: 4AB9A68C.2030002 () fastmail ! fm
[Download RAW message or body]

My earlier MinGW cross-compiling of Fortran on Fedora 11 example (which
used static linking for convenience and brevity) was:

sudo yum install mingw32-gcc-gfortran -y
cat >hellofortran.for <<EOF
      PROGRAM HELLO
      PRINT*, 'Hello Fortran World!'
      END
EOF
i686-pc-mingw32-gfortran -static -o hellofortran.exe hellofortran.for

The resulting (static) binary can be run in WINE by doing

  sudo yum install wine -y
  wine hellofortran.exe

To create and run a dynamically linked equivalent .exe file, one can do

  i686-pc-mingw32-gfortran -o hellodynamicfortran.exe hellofortran.for

At this stage, running this in WINE fails, with an error about a missing
library.  Copying that library (DLL) to the same place as the .exe file
solves this, just as it would in Windows itself, so

  cp -p /usr/i686-pc-mingw32/sys-root-/mingw/binlibgcc_s_sjlj-1.dll .
  wine hellodynamicfortran.exe

works fine, as expected.  You could alternatively copy the DLL to
wherever WINE searches for DLLs on Fedora 11, but since it will search
in the location of the executable too, I saved myself the trouble of
looking for the "system" DLL locations I could have used (perhaps by
running wine cmd /c path ) and just copied the DLL to . for this example
of dynamic linking in a cross-compiled target environment.

I trust this satisfactorily demonstrates that there is no direct
relationship between the use of -static and cross-compiling.  You should
use whichever kind of linking makes more sense for the real world code
that you are working with.  Whether you are cross-compiling or not.

Jonathan


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
MinGW-users mailing list
MinGW-users@lists.sourceforge.net

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) Thread hijacking
3) HTML/MIME encoded mail
4) Improper quoting
5) Improper trimming
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic