Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26730 Discussions

Compiling and linking from command line instead of Visual Studio

jirina
Novice
243 Views

I need to be able to compile and link from the command line instead of Visual Studio. I read discussion in this topic to learn how to do that. I thus rebuilt one of the configurations (Release for x64) in Visual Studio (Community 2015, Update 3) with IPS XE 2017 Update 2 and then changed the BuildLog.htm file to a .bat file with the following contents:

Rc /fo "x64\Release/Resources.res" "D:\Test\Resources.rc"

set compiler_options=/nologo /MP /O2 /fpp /I"%MKLROOT%" /I"\include" /fixed /extend_source:132 /Qopenmp /fpscomp:general /Qdiag-disable:8290,8291,5462 /warn:declarations /warn:unused /warn:truncated_source /warn:noalignments /warn:interfaces /assume:byterecl /module:"x64\Release\\" /object:"x64\Release\\" /Fd"x64\Release\vc140.pdb" /libs:static /threads /Qmkl:parallel /c /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\\bin\amd64" /Qm64

ifort %compiler_options% MyApp.for

set linker_options=/OUT:"x64\Release\MyApp.exe" /INCREMENTAL:NO /NOLOGO /DELAYLOAD:"MyAppx64.dll" /MANIFEST /MANIFESTFILE:"x64\Release\MyApp.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /SUBSYSTEM:CONSOLE /STACK:100000000 /IMPLIB:"D:\Test\x64\Release\MyApp.lib" delayimp.lib ..\DLL\x64\GFMx64.lib mkl_intel_lp64_dll.lib mkl_intel_thread_dll.lib mkl_core_dll.lib libiomp5md.lib -qm64 /qoffload-ldopts="-mkl=parallel"

Link %linker_options% "x64\Release\MyApp.obj" "x64\Release/Resources.res"

mt.exe /nologo /outputresource:"D:\Test\x64\Release\MyApp.exe;#1" /manifest "x64\Release\MyApp.exe.intermediate.manifest"

The resulting executable has the same size like the one created by Visual Studio, so I assume everything is OK. What is confusing are two warnings during the linking phase:

LINK : warning LNK4044: unrecognized option '/qm64'; ignored
LINK : warning LNK4044: unrecognized option '/qoffload-ldopts=-mkl=parallel'; ignored

Why are these two options included in the linking command in BuildLog.htm when they are reported unrecognized on the command line?

Also, are all the compiler and linker options listed above needed when the command line is used?

0 Kudos
1 Solution
Lorri_M_Intel
Employee
243 Views

Within Visual Studio, the link-time step actually calls a compiler-tool called "xilink".   Ultimately, xilink also invokes link passing along all the linker options.   The /qm32 and /qoffload switches are options to xilink, not link.

As far as the myriad of command line options; you'll have to decide what you need and what you don't.   I would guess that the compiler option "/Qlocation,link,"..." " is not necessary in the properly invoked command line window, but other than that, really, it's your choice.

            Hope this helps --

                                         --Lorri

PS: Ah, I should add that xilink.exe is necessary if you decide to use the /Qipo switch.   It is xilink that performs the Inter-Procedural Optimizations requested by /Qipo.   Otherwise, you can simply use link.exe.

 

View solution in original post

2 Replies
Lorri_M_Intel
Employee
244 Views

Within Visual Studio, the link-time step actually calls a compiler-tool called "xilink".   Ultimately, xilink also invokes link passing along all the linker options.   The /qm32 and /qoffload switches are options to xilink, not link.

As far as the myriad of command line options; you'll have to decide what you need and what you don't.   I would guess that the compiler option "/Qlocation,link,"..." " is not necessary in the properly invoked command line window, but other than that, really, it's your choice.

            Hope this helps --

                                         --Lorri

PS: Ah, I should add that xilink.exe is necessary if you decide to use the /Qipo switch.   It is xilink that performs the Inter-Procedural Optimizations requested by /Qipo.   Otherwise, you can simply use link.exe.

 

View solution in original post

jirina
Novice
243 Views

Thank you very much for explaining the functionality of link and xilink; it is clear now.

Regarding compiler option, I asked which of them are necessary, because I noticed in another topic, referenced in my original post, that /Qlocation,link is not necessary. The myriad of the other ones is then up to me. :-)

Thank you again for your kind and quick help.

Reply