gfortran,DLL,下划线 [英] gfortran, DLL, underscore

查看:302
本文介绍了gfortran,DLL,下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从第三方DLL访问一些子程序。这些函数使用STDCALL作为调用约定。

I want to access some subroutines from a third party DLL. The functions use STDCALL as the calling convention.

运行 dumpbin / export foo.dll 给了我一些东西:

      ...
      7    6 00004B40 Foo@16
      ...

我使用以下代码编译代码:

I compile my code using:

      gfortran test.f90 -o test.exe -Wl,foo.dll

我得到一个错误:对'_foo _'(注意下划线)的未定义引用。

I get an error: undefined reference to '_foo_' (note the underscores).

我已经尝试添加 -mrtd 编译标志,以及其他标志我googled,都没有用。

I have tried adding the -mrtd compilation flag, as well as other flags I googled, all to no avail.

我怎么能告诉fortran不添加下划线?

编辑:按照顺序。

edit: A bit of clarification is in order.


  1. 我有一个现有的DLL,我没有它的源代码。

  2. 这个DLL是用Visual Basic编写的,如果有帮助的话。

  3. 我想从调用这个DLL fo rtran。

  4. 当我在test.f90中写入时: Foo(1.0d0)我得到一个未定义的引用至'_foo _'链接错误

  1. I have an existing DLL to which I do not have the source to.
  2. This DLL is written in Visual Basic, if it helps.
  3. I want to call this DLL from fortran.
  4. When I write in test.f90: Foo(1.0d0) I get an undefined reference to '_foo_' linkage error


推荐答案

fno-underscoring?

Did you try -fno-underscoring ?

我发现Tobias Burnus(gfortran开发人员)在 http://www.rhinocerus.net/forum/lang-fortran/604847-fortran-dll-call-excel- 2.html (接近尾声) - 他建议使用编译器指令而不是-mrtd。

I found a post by Tobias Burnus (a gfortran developer) at http://www.rhinocerus.net/forum/lang-fortran/604847-fortran-dll-call-excel-2.html (near the end) -- he recommends the use of compiler directives instead of -mrtd.

这篇关于gfortran,DLL,下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆