This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Sun, Oct 23, 2011 at 11:57:32AM -0700, Brad Finney wrote:
foo and bar are identical except for explicitly namng foo as Foo in the bind() expression. Note case is preserved and there is no trailing underscore.
Yes, I did try his suggestion, but missed the addition of the bind(c, name= " "). Thanks for getting me to read more carefully! That does correct the case issue, but not (for me) the underscore issue, which is very puzzling. I took the exact code you listed and got a leading underscore on Foo and bar.
I don't do Windows, so my code did not include
!GCC$ ATTRIBUTES DLLEXPORT::Foo
F:\FlowReader>gfortran -shared -o foo.dll foo.o Cannot export Foo: symbol not found Cannot export bar_: symbol not found collect2.exe: error: ld returned 1 exit status
F:\FlowReader>gfortran -shared -fno-leading-underscore -o foo.dll foo.o Cannot export Foo: symbol not found Cannot export bar_: symbol not found collect2.exe: error: ld returned 1 exit status
These are loader errors. I'm not familiar with how the loader on Windows works. As Tobias noted, you might need to add the stdcall attribute, but I thought that only dealt with who was responsible for cleaning up the call stack.
subroutine foo(n) bind(c, name="Foo") use iso_c_binding !GCC$ ATTRIBUTES DLLEXPORT::Foo integer(c_int) :: n n = n + n write(*,*)n end subroutine foo
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |