This example demonstrates calling a C subroutine from Fortran, using the C interoperability features first introduced in Fortran 2003.
The C subroutine is in a static library project Clib
. This is made a
"dependent
" project of the Fortran main project Fmain, which will cause
the library to be automatically linked in with the Fortran main program.
.sln
fileBuild > Clean Solution
Build > Build Solution
Debug > Start Without Debugging
or press Ctrl-F5
build.bat clean
build.bat release
build.bat debug
build.bat run
In all mixed-language programming, it is important that all the projects link to the same set of run-time libraries, static vs. dynamic, debug vs. release. Microsoft Visual C++ chooses different defaults for this than Intel Visual Fortran - here we have chosen to change the C project from dynamic libraries to static libraries, to match the Fortran.