Debugging Fortran from Visual Studio


Although your Fortran application must be developed in an environment outsideof Visual Studio 6.0, you may need to include your Fortran code as a library or object module in a C or C++ project in Visual Studio 6.0. In most cases, this requires the Visual Studio 6.0 debugger to step through the Fortran code, as well as the Cand C++ code. This section explains how you can integrate Fortran libraries and object modules in Visual Studio 6.0 projects and debug the Fortran code when you debug other portions of your project.

Prior to debugging, you may need to include Fortran modules or libraries in projects that contain C and C++ source files. Although Microsoft does not provide a Fortran compiler with Visual Studio 6.0, you can include Fortran modules in Visual Studio 6.0 projects. To do this, .compile the Fortran library or Fortran module with an option that produces a program debug database. Visual Fortran provides this option with the compiler option -Zi . This is similar to the process you use to create a program debug database for C and C++ programs. This creates a file with a .pdb extension that contains the debug symbols.

After you have a debug version of your Fortran module or library, you can includeit in a C or C++ project. The easiest way to do this is to add the debug version of the Fortran project as input for the Visual Studio linker.

To add the Fortran project

  1. On the Project menu, click Settings .

  2. In the Settings for: list, select Win32 Debug .

  3. Click the Link tab.

  4. In the Object/library modules box, type the name of the Fortran object moduleor library you want to include.

After you add the Fortran project, you need to enter a search path so that the linker can find the module or library you added. The path must include the current working directory and the directories specified in the Options dialog box.

To add a new folder to the search path

  1. On the Tools menu, click Options .

  2. Click the Directories tab.

  3. In the Show Directories for: list, select Library files .

  4. Click the empty box at the bottom of the list, and then type the path to the new folder.

Visual Studio does not provide an option to specify the path for the .pdb file for your Fortran module. Therefore, you need to place the .pdb file in the same directory as the library or object module you want to include.

You can also add a Fortran module or library directly to the project.

To add a Fortran object module or library directly

  1. On the Project menu, click Add to Project , and then click Files . The Insert Files into Project box appears.

  2. In the Files of Type list, select .obj or .lib , depending on whether you needto insert an object module (.obj) or library (.lib).

  3. Select the file and path for the Fortran object module or library you want to add from the main list displayed.

Now you are ready to start debugging. You can start the debugger and step through code in either the C/C++ source, or the Fortran source.

You can also use binaries created with the Zi compiler option with other Microsoft debug tools, such as WinDBG.

You may need to include a Fortran object module or library in a Visual Studio 6.0 project where a debug version of the object module or library is not available, or you may not need to include the Fortran routines in your debug session. If you do not need to debug the Fortran modules in a Visual Studio 6.0 project, you can include the release versions of either the object module or library as part of the link. You can continue to debug the C or C++ code. However, the debugger will not step into the Fortran source when a Fortran routine is entered. To accomplish this, include the release version of the Fortran object module or library in the All Configurations section of the Project Settings dialog box.

If you do need to include Fortran code as part of your debugging, rememberto also include the release versions of the Fortran object module or library in the Win32 Release section of the Project Setting dialog box.




UNIX Application Migration Guide
Unix Application Migration Guide (Patterns & Practices)
ISBN: 0735618380
EAN: 2147483647
Year: 2003
Pages: 134

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net