Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28446 Discussions

How to use MSVS 2010 for building a C executable that points to both C and Fortran .libs

Robert_Massey
Beginner
305 Views

I am a previousCompaq Visual Fortran user just beginning to gain familiarity with MS Visual Studio.

I am trying to stand up existing C and Fortran code. The main .c program calls the driver routine for the Fortran via an extern void [fortran_program_name_entry_] statement.

The Fortran code then calls mostly fortran routines, but also some c routines.

Within MSVS -> File -> New Project options, I do not see a meansto set up a "mixed project" that would include both C and Fortran routines, within whichI wouldinclude all existing.f and .inc files along with all.c and .h files.

Therefore my current strategy is to create an Intel Visual Fotran Static Library project (containing all ofthe .f and .inc files), and a Visual C++ Class Library Project (containing all of the .c and .h files). The Build products by each of those projects would be .libs.

I would thenlike to create a Main C project as a Win 32 Console Application containing only the main.c program (driver routine). The build product from that project would be an executable thatIcouldrun ina console window. Ultimately I would like to write a test driver routine and invoke the debugger to step through the code top to bottom.

What is the correct approach for building a C executable with both Fortran and C .lib dependendies?Within MSVS, I don't see how to point the C exe to Fortran and C .libs.

In general, I'm not sure if what I've described here is the best strategy or even a viable strategy. Is there anydocumentation specific to what I'm trying toaccomplish?

I appreciate any/all advice and guidance on the best approach for standing up a C driver that invokes Fortran which in turn calls other Fotran and C routines, and ultimately for adding a driver to invoke the debugger.

Thank you

0 Kudos
3 Replies
JenniferJ
Moderator
305 Views
what you tried should work in VS IDE.
1) main project: win32 C/C++ project
2) Fortran lib: a Fortran static lib or dynamic dll project
3) C lib project: win32 C/C++ statid or dynamic dll project

Under [Project] menu, select "Project Dependency" to add the dependency like below:
. Fortran lib project: depend on C lib project
. main project: depend on Fortran lib project

then it should be ready to go.

There is a big section talking about mixed C/Fortran language programming in the Fortran user's guide.

I feel that your question might be better answered in our Fortran forum in case my answer above is not enough, so let me transfer this to there.

thanks,
Jennifer
0 Kudos
Robert_Massey
Beginner
305 Views
Thank you Jennifer,
Good to know the approach is sound.
I'll consult the Fortran User's Guide.
0 Kudos
Reply