使用Ifort编译C和Fortran

发布于 2025-01-31 16:43:01 字数 657 浏览 3 评论 0原文

我试图使用Fortran从C中称为简单的“ Hello World”代码。当我使用ifort编译时,它给我“错误lnk2019:未解决的外部符号helly helly helly in function main __”

c代码:

#include <stdio.h>

void hello_(){

    printf("Hello World :) \n");
}

fortran代码:

       program Fortran_C_Link_Test
C
      implicit None
C
      call hello()
C
      stop
      end

我如何编译:

cl -c c_src.c 

生成e : c_src.obj对象文件

ifort -c fortran_src.f 

生成fortran_src.obj对象文件

ifort -o program c_src.obj fortran_src.obj

以生成可执行文件

I am trying to call a simple "Hello World" code from C using Fortran. When I compile using iFort, it is giving me "error LNK2019: unresolved external symbol HELLO referenced in function MAIN__"

C Code:

#include <stdio.h>

void hello_(){

    printf("Hello World :) \n");
}

Fortran Code:

       program Fortran_C_Link_Test
C
      implicit None
C
      call hello()
C
      stop
      end

How I Compiled:

cl -c c_src.c 

to generate the c_src.obj object file

ifort -c fortran_src.f 

to generate the fortran_src.obj object file

ifort -o program c_src.obj fortran_src.obj

to generate the executable

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文