Quantcast
Viewing all articles
Browse latest Browse all 3270

Difficulties building/linking with ISO C binding with ifort on Windows

Big picture: I am trying to embed a Lua interpreter in Fortran code via the F2003 ISO C bindings (see https://bitbucket.org/haraldkl/aotus ).

I can get it to work with ifort and Windows, just not both at the same time ('it works' means 'a C library is built and example Fortran code using the Lua bridge builds and produces the expected results'). gfortran/gcc works on both Windows and Linux, ifort/gcc works on Linux, but neither ifort/msvc or ifort/gcc works on Windows. The C code is ANSI C and the Fortran is plain F2003; there's no screwy preprocessor stuff, platform-specific nonsense, or operating environment weirdness like Cygwin. This isn't exactly a trivial problem but as I said, I've successfully built this code with gfortran/gcc on both Windows & Linux and with ifort/gcc on Linux so the problem is not with the code or the operating systems. I expect it should build with ifort on Windows but I cannot figure out the magic words to make that happen.

The C portion of the project compiles without incident and is packed into a few static libraries (libaotus.a, libflu.a, liblualib.a) with ar which comes from the TDM distribution of gfortran and gcc for Windows. I'm not worried about this part since this code works fine if I build the code with gfortran.

The automated build tool used by the project (waf) fails with ifort on Windows so I'm trying to manually convert the compilation steps which use gfortran to ifort. I have a reasonable amount of success until I try linking with the C libraries which is where everything falls apart.

Here's an example of where conversion is failing - first the (successful) compilation step:

 

@REM [46/84] Compiling LuaFortran\examples\test.f90
@REM gfortran.exe -O3 -march=native -Wall -Wconversion -Wimplicit-interface -Wunderflow -W -frange-check -c -o .\LuaFortran\examples\test.f90.8.o ..\LuaFortran\examples\test.f90
ifort.exe /O3 /warn=all /fpe:0 /warn=interfaces /gen-interfaces -c -o .\LuaFortran\examples\test.f90.8.o ..\LuaFortran\examples\test.f90

Then a few lines later, the unsuccessful link step:

 

@REM [49/84] Linking build\flu_sample.exe
@REM gfortran.exe -Wl,--enable-auto-import -Wl,--enable-auto-import -O3 -march=native -Wall -Wconversion -Wimplicit-interface -Wunderflow -W -frange-check LuaFortran\examples\test.f90.8.o -o .\flu_sample.exe -L. -lflu
@REM -Wl,--enable-auto-import -Wl,--enable-auto-import ; superfluous linker directives; only suppresses warnings which may not exist with ifort
ifort.exe /O3 /warn=all /fpe:0 LuaFortran\examples\test.f90.8.o -o .\flu_sample.exe /LIBPATH:. -lflu

 

I'm almost certain the problem is in the unixy '-lflu' argument to ifort which (I believe) is passed directly through ifort to LINK.EXE, which, as far as I can tell, is not meant for humans to understand or manipulate directly. I believe if I can get the linking sorted out, the rest of the project will fall into place.

What's the right way to resolve this?

Is there a way to tell ifort to ignore Microsoft's infrastructure and just use C:\TDM-GCC-64\bin\ld.exe which (apparently) works?

Note that I typically work with either pure Fortran or interpreted languages. If I'm faced with a linking problem, it usually indicates I'm using the wrong language or platform. I've been fighting with this for a week or two now trying to get it to build with ifort on Windows, and passing whatever knowledge I gather back to the upstream project (I'm not directly involved in the Lua/Fortran bridge development). I've helped improve the automated build system's detection of ifort, but so far it's been a miserable slog on Windows. Any help you could provide would be greatly appreciated.


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>