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

LInking error while compiling using ifort

NR6
Beginner
1,213 Views

NR6_0-1678662021419.png

I get the error shown above while compiling using ifort.exe.  I have following installed:

C:\Program Files\Microsoft Visual Studio\2022

C:\Program Files (x86)\Intel\oneAPI

C:\Program Files (x86)\Microsoft Visual Studio

 

Thanks for your help.

 

NR6

0 Kudos
11 Replies
mecej4
Honored Contributor III
1,195 Views

You are probably lacking the following prerequisite:

 

Microsoft Visual Studio*

  • Microsoft Visual Studio* 2019 or 2022 Community, Enterprise and Professional Editions with 'Desktop development with C++' component installed

Verify by opening a OneAPI or Visual Studio developer command prompt, and entering the "link /?" command. If you do not have the Microsoft C compiler and tools installed, run the Visual Studio installer again and ask for the C++ desktop development tools package to be added.

NR6
Beginner
1,144 Views
I checked the installation and tried link/? Command in oneapi cmd prompt.

I also traced the link.exe file to the visual studio folder. Link cmd is recognized in oneapi cmd prompt but not from folder where my Fortran code resides.

Btw, does it matter that ms visual studio is in c/program files and not in c/program files (x86) where intel stuff is.

Do I need set path for link.exe and if so where and how

Thanks
0 Kudos
Steve_Lionel
Honored Contributor III
1,134 Views

How are you starting your command prompt session. Ideally you would use the Intel installed shortcut under All Apps > Intel oneAPI 2023 > Intel oneAPI Command Prompt for Intel 64 for Visual Studio 2022. If you have manually added things to PATH for this, you'll miss a lot.

Show us the complete output from when you started the command prompt session to the command that gets the error.

NR6
Beginner
1,078 Views

Please see the attached files:

first three showing the link/? checks I did at oneapi cmd and where the link files are

fourth one showing the link error i get while compiling .f file using ifort

Thanks for your time and help

 

0 Kudos
Steve_Lionel
Honored Contributor III
1,072 Views

I notice that the output you show where link works are all (apparently) from using the Intel shortcut, which ends up with your default folder being the Intel install folder. Then when it doesn't work, you're now in a different folder. This suggests to me that when you issued the ifort command, you were NOT in the environment created by the Intel shortcut.

What I wanted to see was a continuous display from where you started the session to where you got the error. Something like:

:: initializing oneAPI environment...
   Initializing Visual Studio command-line environment...
   Visual Studio version 17.5.0 environment configured.
   "C:\Program Files\Microsoft Visual Studio\2022\Community\"
   Visual Studio command-line environment initialized for: 'x64'
:  compiler -- latest
:  debugger -- latest
:  mpi -- latest
:: oneAPI environment initialized ::

D:\Projects>ifort t.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.8.0 Build 20221119_000000
Copyright (C) 1985-2022 Intel Corporation.  All rights reserved.

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

-out:t.exe
-subsystem:console
t.obj

If I had to guess (which I do), I'd say that you are NOT executing the ifort command from the Intel build environment but rather from some other setup which does not have the complete environment.

 

0 Kudos
NR6
Beginner
1,062 Views
I start the session as shown in image 4 above.

That is

Open cmd prompt

CD to directory where .f file is

Then type
ifort fn.f

That’s what I am supposed to do if all the paths are set correctly

Just fyi that I did the same thing a few months ago and it worked and I could compile link and get .exe file. I still have that and it works fine

Because of computer issues I have to reinstall the visual studio basic and hpc api again two weeks ago, however now I can not compile any new Fortran file anymore

You think I need to set any path in env

Thanks
0 Kudos
jimdempseyatthecove
Honored Contributor III
988 Views

>>I start the session as shown in image 4 above.
>>That is
>>Open cmd prompt
>>CD to directory where .f file is

This does not state that you explicitly opened the oneAPI command prompt (as you did in the 2nd and 3rd .png files)...

but rather opened the cmd prompt by other means (Start | Run | cmd).

Therefor, start the oneAPI command prompt (as you did in the 2nd and 3rd .png files).

Then CD to your development folder (you may additionaly issue the link /? prior to CD to confirm link is found).

Jim Dempsey

 

NR6
Beginner
968 Views
0 Kudos
Steve_Lionel
Honored Contributor III
1,058 Views

Ah, big "if". Your paths are NOT set correctly. If you want to do it from a bare cmd prompt, then type the following command first:

call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64 vs2022

Or, use the shortcut installed under Start > All Apps > Intel oneAPI 2023

0 Kudos
NR6
Beginner
1,045 Views
Tried that as well.

Otherwise it does not recognize ifort command as well

Thanks
0 Kudos
Steve_Lionel
Honored Contributor III
1,011 Views

Show us, please.

0 Kudos
Reply