- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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.
コピーされたリンク
2 返答(返信)
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
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.
