Compiling and Linking Mixed-Language Programs

Your application can contain both C and Fortran source files. If your main program is a Fortran source file (myprog.for) that calls a routine written in C (cfunc.c), you could use the following sequence of commands to build your application:

  cl -c cfunc.c
  DF myprog.for cfunc.obj /link /out:myprog.exe

The cl command (invokes the C compiler) compiles but does not link cfunc.c. The -c option specifies that the linker is not called. This command creates cfunc.obj. The DF command compiles myprog.for and links cfunc.obj with the object file created from myprog.for to create myprog.exe.

For more information about compiling and linking Visual Fortran and Visual C++ programs, and the libraries used, see: