【问题标题】:Calling a C DLL from Fortran从 Fortran 调用 C DLL
【发布时间】:2019-06-20 21:18:46
【问题描述】:

我已经使用 __declspec(dllexport) VLENCODER f(...); 在 C 语言中创建了一个 DLL;我想使用 iso_c_binding 功能从 Fortran 调用它。我已经声明了以下接口:

function create_vlencoder_c(appKey) bind(C, name="create_vlencoder")
    use iso_c_binding
    implicit none         
    type(c_ptr) :: create_vlencoder_c
    character(len=1, kind=c_char), intent(in) :: appKey(*)
end function

但是,在链接时,编译器会抱怨找不到符号 _create_vlencoder。显然,dependency walker 告诉我,DLL 中我的名字前面没有下划线。如何防止 Fortran 编译器在我的 C 函数名称中添加下划线?

PS:我在 Windows 上为 C 和 Fortran 使用 Intel 编译器。

【问题讨论】:

标签: c dll fortran


【解决方案1】:

对不起。我更像是一个 unix 用户,不习惯 Visual Studio。 Fortran 代码是 32 位的,而 C 代码是 64 位的,这会导致装饰不同,从而导致问题。

【讨论】:

    猜你喜欢
    • 2019-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多