在 Visual Studio 2008 中从 Intel Fortran 11 调用 C 函数分步过程
请给我一个逐步的答案,例如如何在 Visual Studio 2008 中从 Fortran 调用 C 函数。我的 Fortran 编译器正在 Visual Studio 2008 中工作。我应该在哪里保存 C 和 Fortran 文件,为此我需要一个 C编译器与否?
Please give me a step by step answer with example, how to call a C function from Fortran in visual studio 2008. My Fortran compiler is working in visual studio 2008. Where I should keep the C and Fortran files and for this I need a C compiler or not?.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
您最好使用 Windows 构建环境,例如 MinGW。安装它并确保包含 gcc.exe、make.exe 等的 MinGW 目录位于您的路径中。您需要帮助进行设置吗?
接下来,编写 C 文件并将其编译为目标文件:
例如,您的 c 文件可能是:
现在您需要为 C 函数提供 Fortran 编译器的接口:
您需要告诉链接器有关目标文件的信息c_file.obj。我假设您使用的是 Visual Studio IDE。转到项目属性 ->链接器->输入,并将c_file.obj添加到“附加依赖项”中。然后它应该可以正常工作。
You are best off using a Windows build environment such as MinGW. Install that and make sure the MinGW directory containing gcc.exe, make.exe etc is in your path. Do you need help setting that up?
Next you write the C file and compile it to an object file:
For example, your c file might be:
Now you need to provide an interface to the Fortran compiler for the C function:
You will need to tell the linker about the object file c_file.obj. I'm assuming you're using the Visual Studio IDE. Go to Project Properties -> Linker -> Input, and add c_file.obj to "Additional dependencies". It should then work fine.