Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ifort with MingW

Sagan__David
Beginner
2,912 Views

I have to use the MingW environment for a project on Windows due to some compile scripts not being workable under Visual Studio. I would like to use ifort with MingW but I don't know how to set this up (Note: I already use ifort with VS). Is this possible? Thanks for any help.

0 Kudos
11 Replies
TimP
Honored Contributor III
2,912 Views

Do you mean that you use C - Fortran interoperability and wish to use gcc or g++ in place of ICL or C++?  This seems to imply run-time library conflicts, as the Microsoft libraries are required by ifort.

On the other hand, if you use gnu make or a shell such as bash, that should be feasible to use with ifort/cl command line.

0 Kudos
Sagan__David
Beginner
2,912 Views

C - Fortran interoperability is needed eventually but for now I just want to be able to compile/link with ifort on the command line. Now if I type "which ifort" in MingW I get nothing so there is a setup that is needed and I am not able to find any information on the web on how to do this. Thanks for any help.

0 Kudos
IanH
Honored Contributor II
2,912 Views

Start a normal ifort command prompt, then from within that command run x:\mingw\msys\1.0\msys.bat.  That should have you running in an msys shell environment (is that what you mean by "the MinGW environment"?) with all the ifort environment variables set correctly.
 

0 Kudos
TimP
Honored Contributor III
2,912 Views

If Ian's advice results in ifort picking the wrong link command, you can set the -Qlocation,link option for ifort to point to the Microsoft VC\bin or VC\bin\amd64 folder where their link.exe resides.

I hesitated to answer along the lines which Ian did because I didn't know what you meant by MinGW environment, and didn't want to ask too many off-topical details.

0 Kudos
Sagan__David
Beginner
2,912 Views

By "MinGW environment" I mean a shell running MinGW.  In response to Ian's post, I start with a shell with ifort setup (the ifort command is reognized). One problem now is that there is no file I can find with a name that is close to "msys.bat" (I am running msys2 not msys). So instead I run C:\msys64\mingw64.exe which spawns a shell running MinGW. Now the problem is that the ifort command is not defined.

Now in the MinGW shell I use the following commands to setup ifort:

  '/c/Program Files (x86)/Intel/Composer XE 2015/bin/ipsxe-comp-vars.bat' intel64 vs2010

  export PATH=${PATH}:'C:\Program Files (x86)\Intel\Composer XE 2015\bin\intel64'

But now using ifort the linking fails with  "link: unknown option --s". I assume this is the linker picking the wrong link command as per Tim's comment. However I don't understand how to "set the -Qlocation,link option".

Anyone have any ideas? -- Thanks.

0 Kudos
andrew_4619
Honored Contributor II
2,912 Views

I guess there is a GNU link.exe earlier in the PATH than the Ifort linker.

 

0 Kudos
IanH
Honored Contributor II
2,912 Views

So... I think you are using mingw-w64 and want to work in an MSYS2 environment running the bash shell or similar.  If so, as TimP suggests try something like:


>h:\msys64\usr\bin\bash.exe

ian@DOLORES  /u/projects/FortranMisc/2016
$ PATH=/bin:$PATH

ian@DOLORES  /u/projects/FortranMisc/2016
$ cat 2016-08-17\ helloworld.f90
PROGRAM HelloWorld
  IMPLICIT NONE
  PRINT "(A)", 'Hello world'
END PROGRAM HelloWorld

ian@DOLORES  /u/projects/FortranMisc/2016
$ ifort 2016-08-17\ helloworld.f90 /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64"
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0 Beta Build 20160517
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

ifort: NOTE: The Beta evaluation period for this product ends on 7-oct-2016 UTC.
Microsoft (R) Incremental Linker Version 14.00.24213.1
Copyright (C) Microsoft Corporation.  All rights reserved.

"-out:2016-08-17 helloworld.exe"
-subsystem:console
"2016-08-17 helloworld.obj"

ian@DOLORES  /u/projects/FortranMisc/2016
$ ./2016-08-17\ helloworld.exe
Hello world


 

0 Kudos
TimP
Honored Contributor III
2,912 Views

No, the path set in location,link is the folder in the vs installation which contains link.exe. for intel64:

-Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\AMD64"

0 Kudos
Sagan__David
Beginner
2,912 Views

Thanks Ian and Tim. I found where the link.exe was but now I get a different error:

Etienne@Etienne-PC MINGW64 ~/bmad_dist
$ ifort Hello.f90 /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Intel Fortran\Microsoft Files\VC\Bin\amd64"
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.1.148 Build 20141023
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:Hello.exe
-subsystem:console
Hello.obj
LINK : fatal error LNK1104: cannot open file 'ifconsol.lib'

Any thoughts? My environmental variables are:

$ printenv
HOMEPATH=\Users\Etienne
APPDATA=C:\Users\Etienne\AppData\Roaming
MANPATH=/mingw64/share/man:/usr/local/man:/usr/share/man:/usr/man:/share/man
ACC_CMAKE_VERSION=2.8.5
ACC_EXE=/home/Etienne/bmad_dist/production/bin
ProgramW6432=C:\Program Files
ORIGINAL_TEMP=/c/Users/Etienne/AppData/Local/Temp
HOSTNAME=Etienne-PC
ORIGINAL_TMP=/c/Users/Etienne/AppData/Local/Temp
DIST_OS=MINGW64_NT-6.1
INTEL_LICENSE_FILE=C:\Program Files (x86)\Common Files\Intel\Licenses
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
TERM=xterm
SHELL=/usr/bin/bash
ACC_DEBUG=/home/Etienne/bmad_dist/debug/bin
KMP_DUPLICATE_LIB_OK=TRUE
WINDIR=C:\Windows
DIST_BUILD=TRUE
GINODATA=C:\Users\Public\Documents\gino\v8.0
ACC_BUILD_SYSTEM=/home/Etienne/bmad_dist/build_system
PGPLOT_FONT=/home/Etienne/bmad_dist/PGPLOT/grfont.dat
ACC_PLOT_DISPLAY_TYPE=QT
PUBLIC=C:\Users\Public
OLDPWD=/c/Users/Etienne/Desktop
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
G95_LIBRARY_PATH=C:\Program Files\g95\lib\gcc-lib\i686-pc-mingw32\4.1.2;C:\Program Files\g95\lib
USERDOMAIN=Etienne-PC
ORIGINAL_PATH=/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/
MSYSTEM_CHOST=x86_64-w64-mingw32
ALLUSERSPROFILE=C:\ProgramData
MIC_LD_LIBRARY_PATH=C:\Program Files (x86)\Common Files\Intel\Shared Libraries\compiler\lib\mic
OS=Windows_NT
IFORT_COMPILER15=C:\Program Files (x86)\Intel\Composer XE 2015\
windows_tracing_flags=3
BMAD_LAYOUT=/home/Etienne/bmad_dist/config/bmad/layout
!::=::\
GINO=C:\ginointel32
windows_tracing_logfile=C:\BVTBin\Tests\installpackage\csilogfile.log
USER=Etienne
TEMP=/tmp
COMMONPROGRAMFILES=C:\Program Files\Common Files
VS90COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\
temp=C:\Users\Etienne\AppData\Local\Temp
tmp=C:\Users\Etienne\AppData\Local\Temp
GCC_MINOR_VER=1
DIST_CONFIG=/home/Etienne/bmad_dist/config
ACC_BUILD_EXES=Y
IFORT_COMPILER13=C:\Program Files (x86)\Intel\Composer XE 2013\
QTJAVA=C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
DIST_F90=gfortran
CONFIG_SITE=/mingw64/etc/config.site
USERNAME=Etienne
ACC_COMPILER_TOOLSET=mingw64-msys
DIST_PLATFORM_VERSION=2
DIST_UTIL=/home/Etienne/bmad_dist/util
PROCESSOR_LEVEL=6
INTEL_DEV_REDIST=C:\Program Files (x86)\Common Files\Intel\Shared Libraries\
ProgramFiles(x86)=C:\Program Files (x86)
ACC_ENABLE_OPENMP=N
PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/Etienne/bmad_dist/util:C:\Program Files (x86)\Intel\Composer XE 2015\bin\intel64
BMAD_LAT=/home/Etienne/bmad_dist/config/bmad/lat
MINGW_PACKAGE_PREFIX=mingw-w64-x86_64
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
FP_NO_HOST_CHECK=NO
SYSTEMDRIVE=C:
PWD=/home/Etienne/bmad_dist
VSSHELL2010INSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio 10.0\
DIST_BASE_DIR=/home/Etienne/bmad_dist
USERPROFILE=C:\Users\Etienne
LANG=en_US.UTF-8
ACC_ENABLE_SHARED=N
MSYSTEM_PREFIX=/mingw64
ACC_ENABLE_MPI=N
TZ=America/New_York
PS1=\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[35m\]$MSYSTEM\[\e[0m\] \[\e[33m\]\w\[\e[0m\]\n\$
LOGONSERVER=\\ETIENNE-PC
DIST_MOD=/home/Etienne/bmad_dist/modules
CommonProgramW6432=C:\Program Files\Common Files
MINGW_CHOST=x86_64-w64-mingw32
LOCALAPPDATA=C:\Users\Etienne\AppData\Local
PROCESSOR_ARCHITECTURE=AMD64
DIST_ARCH=x86_64
DIST_SETUP_QUIET=N
ProgramData=C:\ProgramData
HOME=/home/Etienne
SHLVL=1
ACC_ROOT_DIR=/home/Etienne/bmad_dist
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
GCC_VER_STR=GNU Fortran (Rev1, Built by MSYS2 project) 6
USE_CWD_BASEDIR=Y
HOMEDRIVE=C:
MSYSTEM_CARCH=x86_64
GCC_MAJOR_VER=6
PGPLOT_DIR=/home/Etienne/bmad_dist/PGPLOT
COMSPEC=C:\Windows\system32\cmd.exe
MSYSTEM=MINGW64
TMP=/tmp
SYSTEMROOT=C:\Windows
PROCESSOR_REVISION=2a07
PRINTER=Canon MP990 series USB
ACC_SET_GMAKE_JOBS=1
DIST_EXE=/home/Etienne/bmad_dist/bin
DIST_INC=/home/Etienne/bmad_dist/include
CLASSPATH=.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
DIST_F90_REQUEST=gfortran
ACC_ENABLE_GFORTRAN_OPTIMIZATION=Y
PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
DIST_OS_ARCH=MINGW64_NT-6.1_x86_64
ACLOCAL_PATH=/mingw64/share/aclocal:/usr/share/aclocal
MINGW_PREFIX=/mingw64
PROGRAMFILES=C:\Program Files
INFOPATH=/usr/local/info:/usr/share/info:/usr/info:/share/info
ACC_PLOT_PACKAGE=plplot
NUMBER_OF_PROCESSORS=4
DIST_LIB=/home/Etienne/bmad_dist/lib
TAO_DIR=/home/Etienne/bmad_dist/tao
SESSIONNAME=Console
DIST_PLATFORM=MINGW64_NT-6.1_x86_64_gfortran
COMPUTERNAME=ETIENNE-PC
_=/usr/bin/printenv

 
0 Kudos
Kevin_D_Intel
Employee
2,912 Views

You need at least a LIB setting. You can get the needed details from an Intel compiler pre-initialized command-prompt. Command-prompt shortcuts are under a path like:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Intel Parallel Studio XE 2015\Compiler and Performance Libraries\Command Prompt with Intel Compiler XE v15.0 Update 1

Start the command-prompt for the Intel 64 environment and then just echo it with:  echo %LIB%
 

0 Kudos
Sagan__David
Beginner
2,912 Views

OK that worked. Much thanks.

Procedure was:
On intel side:
   echo %LIB%
On MingW side:
   export LIB='stuff-from-intel-side'

 

0 Kudos
Reply