Reputation: 57
I have two files source1.f90
and main.cpp
. The Fortran file has a subroutine and the cpp file has a program that calls the Fortran subroutine
I compiled the Fortran file and the built a static library file using the following command line options
ifort source1.f90 /nologo /debug:full /Od /gen-interfaces /warn:interfaces /traceback /check:bounds /libs:static /threads /dbglibs /c
lib /out:lib1.lib source1.obj
But when I compiled the cpp file using
CL main.cpp /link LIB1.LIB
I get the following error
D:\temp>CL main.cpp /EHsc /link LIB1.LIB
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.60610.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
main.cpp
Microsoft (R) Incremental Linker Version 11.00.60610.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:main.exe
LIB1.LIB
main.obj
LINK : fatal error LNK1104: cannot open file 'ifmodintr.lib'
How do I fix this problem so that my program compiles?
Upvotes: 2
Views: 3282
Reputation: 124
Generally speaking, you miss the setting of the mixed programming environment in Visual studios. Just follow this link provided by intel: https://software.intel.com/en-us/articles/configuring-visual-studio-for-mixed-language-applications.
Or in short, add the fortran compiler include directory and library directory in the project configuration tab. In my case, the fortran compiler directory is "g:\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\compiler\include\intel64", and the library directory is "g:\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\compiler\lib\intel64_win".
Upvotes: 1