LF Fortran

How To: Migrate Existing Code Into Visual Studio


If you have existing source code for a program or library that builds with lf95, you can easily use that code in the Microsoft Visual Studio IDE and you can take advantage of all the rapid development features of Visual Studio with the LF Fortran integration. You will be able to edit source code, set compiler and linker options, build, and debug your program all within Visual studio.

The existing code can be one file, or many. It might be built with a makefile, a batch file, or Automake. It might need to be linked with external libraries, object code, or external modules. Source can be in fixed or free format, or a combination. Migrating code into Visual Studio can be accomplished for all of these scenarios.

Visual Studio uses a basic structure to organize code called the "Solution". The Solution is the top-level container, and will include one or more "Projects". Projects correspond to the main output types of lf95 such as a library, or an application. Projects contain all the information required to compile the source code into an application or library. When the source code is added to a Project, each source file is displayed as a Project Item.

The Project allows you set compiler and linker options for all the source files in a project as a group, or for each source code file individually. External references to modules or libraries that are needed for compiling and/or linking can also be added to the Project. Include files are automatically detected and added as sub-items to the source code Project Item in which they are referenced.

For more information about Visual Studio Fortran integration features see Developing with Visual Studio.


  1. Determine what kind of output your current build creates (i.e., Console application, Windows application, library, Fortran module(s), or DLL). This will be the kind of Project you create first.
  2. Determine if you want to add other Projects to better organize your Solution. For example, you might put all of your global procedures in a separate Project and all of your modules in another Project.
  3. Determine what external references (components for which you do not have the source code) you will need to add (e.g., libraries, modules, objects).