- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a Visual Studio 2012 installed on Windows 8.1. Also, I installed Visual Fortran. I want to create a solution with two projects one in Fortran and one in C, then be able to call C function from Fortran code. Can anyone, please, show a simple step by step example on how to achieve this in VS? Thanks.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a Fortran_Calls_C sample provided in Mixedlanguage.zip under Samples. But the general steps are:
- Create the executable project (Fortran in this case)
- Right click on the Solution under Solution Explorer and select Add... New Project...
- Select Visual C++ > Win32 > Win32 Project. Name the project whatever you want and also specify where it is to be placed.
- When the project wizard opens, click Next and then change Application Type to Static Library. Make any other changes you want here and click Finish.
- Right click on your Fortran project and select Project Dependencies, Under "Depends On" you will see your C++ project listed - check the box next to it, then click OK.
Now you have the projects set up properly. Make sure you are naming and calling the C++ routine properly. Using the Fortran standard features for C interoperability will be helpful. Note that if your source file is .cpp and not .c, you will need to add 'extern "C"' before any functions you want Fortran to call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page