Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29608 ディスカッション

Link error when running Intel Fortran compiler from command line

dbeerer
ビギナー
5,856件の閲覧回数

Hi,

I am running into the following error when trying to compile a .for file from the command line:

LINK: fatal error LNK1104: cannot open file ‘kernel32.lib’

 

For background, I have Microsoft Visual Studio 2022 and Intel Fortran 2024.0 on my workstation with Windows 10.

 

I open the 'OneAPI Command Prompt for IA32 Visual Studio 2022' from the start menu. After it initializes I navigate to the directory with my simple hello.for file.  I try running the command:

ifort hello.for 

I get the following lines:

-out:hello.exe 
-subsystem:console
hello.obj
LINK: fatal error LNK1104: cannot open file ‘kernel32.lib’

In terms of troubleshooting I've searched for the kernel32.lib and see it does exist in the following directories on my machine:
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\arm\kernel32.lib
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\arm64\kernel32.lib
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\kernel32.lib
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x86\kernel32.lib


Also, I did make a New Project in the normal Visual Studio 2022 environment and added the hello.for file there. There I was successful in building, compiling and running the program. So for some reason trying to compile through the command line is not finding that file.

Any suggestions on what I might do to troubleshoot, would be greatly appreciated. 
-David

 

 

0 件の賞賛
11 返答(返信)
Steve_Lionel
名誉コントリビューター III
5,839件の閲覧回数

Does the message really say 'kernal32.lib'? If so, you've misspelled it in your command.

dbeerer
ビギナー
5,809件の閲覧回数

That is a typo on my end... the error message was kernel32. lib. I edited the original post. 

Steve_Lionel
名誉コントリビューター III
5,767件の閲覧回数

In this environment, do a:

set lib

what is the output? Please show a log of the entire command session from start to error.

In the future, please use copy-and-paste and don't retype messages, as it can sidetrack and delay responses.

dbeerer
ビギナー
5,588件の閲覧回数

Here is the output when I command the set lib after I open OneAPI command prompt:

dbeerer_2-1725397049396.png

 

dbeerer_3-1725397608154.png

 

I noticed on another machine where this is working the LIB path also includes:

C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\ucrt\x86;

 C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22621.0\\um\x86

But I don't see them in the troubled machine's path. I'm not sure what's the difference.  Is there a way to specifically call these paths through the command line? Or is there a way to call these paths in the Visual Studio environment? 

 

This is what I see in the Visual Studio environment when I scroll to Tools->Options:

dbeerer_1-1725396968443.png

 

Thank you for your assistance and patience. 

dbeerer
ビギナー
5,473件の閲覧回数

If there is anything else to help diagnose you need, please feel free to let me know. 

Ron_Green
モデレーター
5,443件の閲覧回数

On this troublesome "other system", did you install VS 2022 including the Microsoft C++ tools?  If just command line, did you install MS Build Tools 2022 AND the MS C++ components?  Those are still needed for command line builds.  

AND

Did you install the MS tool chain BEFORE installing Intel Fortran?  Those have to be in place first so the installer can set up LIB and PATH correctly to your MS tool chain.

dbeerer
ビギナー
5,429件の閲覧回数

Hi,

I followed the instructions on this site:
https://www.intel.com/content/www/us/en/developer/articles/guide/installing-microsoft-visual-studio-2019-for-use-with-intel-compilers.html

I did check off the Desktop Development with C++ box during the VS install. I didn't modify the installation details on the right. Is there any one box I should double check was included? Are the MIS Build tools and MS C+++ components automatically installed under the Desktop Development? 

And yes, the MS VS 2019 was installed first and then Intel Fortran 2024 was installed after using the instructions here:
https://www.intel.com/content/www/us/en/developer/articles/training/intel-fortran-compiler-in-ms-visual-studio.html

We I verified that the MS VS 2022 was selected for the Intel Fortran to integrate with. As an extra note, when I open VS 2022 and compile through that environment it works fine. It is only through the command line that I am running into the bug. Not sure if that's a clue or not. 

Thank you,

 

dbeerer
ビギナー
5,170件の閲覧回数

Just for completeness, I was able to resolve the issue for the most part. After opening oneAPI and it's initialization I typed the command

set LIB=%LIB%;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22621.0\\um\x86
which added the directory path for the kernel32.lib file that it could not find. After doing that, I was able to use the ifort command as usual and compile my code. See screenshot below. 

 

Still unclear why this path was not included in the environmental variables. Adding the one command each time I open a new session works, but if anyone knows if there is a way I could add this permanently to the default LIB paths, please let me know. 

 

dbeerer_0-1726171870105.png

 

 

andrew_4619
名誉コントリビューター III
5,153件の閲覧回数

what do you have in libraries:

andrew_4619_0-1726171147095.png

 

dbeerer
ビギナー
5,143件の閲覧回数

It looks the same as yours. Does changing the directory list in the graphical interface of Visual Studio also affect the list when using the OneAPI command prompt? 

andrew_4619
名誉コントリビューター III
5,131件の閲覧回数
I don't know but it is easy enough to test
返信