[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fortran DLLs on mingw32

From: Steve Edwards
Subject: Fortran DLLs on mingw32
Date: Thu, 8 Jan 2009 16:51:27 +0000


This is just a request to find out if anyone out there has tried using
libtool to build Fortran DLLs under mingw32?

We had some Fortran code built as a shared library that could be loaded
into Matlab quite happily on Linux systems and also used as a
conventional library linked against by several programs. We're now
looking to see if we could make that library available on mingw32

We are using automake 1.10.1, autoconf 2.63 and libtool 2.2.6

After a bit of digging around I thought that this would be possible by
adding win32-dll to LT_INIT and adding -no-undefined
to libmattest_la_LDFLAGS in the relevant as mentioned in
the info.

As it is Fortran we can't use the __declspec(dllexport) and __declspec
(dllimport) as mentioned in the docs, but from my limited
understanding, if this is never used, libtool exports all symbols?

This appeared to produce a DLL.

The problem was when a Fortran program in the library package
tries to link against the created DLL (it was actually a test case

It fails with a number of multiple definition errors:


It appears that the DLL creation has pulled in symbols from the
libgfortran compiler runtime?

Am I correct in assuming that this is due to the gfortran runtime not
being available in DLL form?

Provided it is stand alone, this DLL does appear to work in Matlab, but
we cannot link Fortran programs with it.

If we have a .so for Matlab that depends on other libraries, we don't
appear to be able to create those libraries as DLLs (as we would
create .so's on a UNIX system) due to these duplicate symbols that
appear in each DLL.

This does not appear to matter with PE however (PE is always PIC?)

It is very likely that I've misunderstood the whole DLL approach here -
would it make more sense to create static libraries separately for
program linking and manually create a DLL for Matlab loading?

If anyone has any suggestions or pointers, I'd greatly appreciate
hearing them.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]