- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have the simplest example I can think of:
! minimal_example.f90
function add_numbers(a, b) bind(C, name="add_numbers")
integer, intent(in) :: a, b
integer :: add_numbers
add_numbers = a + b
end function add_numbers
I compile this using:
ifx.exe -dll -o minimal_example.dll minimal_example.f90
I then try:
dumpbin /exports minimal_example.dll
I get:
Microsoft (R) COFF/PE Dumper Version 14.42.34435.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file minimal_example.dll
File Type: DLL
Summary
1000 .data
1000 .pdata
1000 .rdata
1000 .reloc
1000 .text
No sign of "add_numbers". What gives?
P.S. I also tried "ifort" with the same results.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ugh! I should never have posted this.
In case anyone else looks to this thread for help, this solved my issue:
integer, value, intent(in) :: a, b
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I guess I posted that too quickly! I found I needed to add:
!DEC$ ATTRIBUTES DLLEXPORT::add_numbers
However, now that I've done that, I'm trying the following P/Invoke declaration:
[DllImport("minimal_example.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int add_numbers(int a, int b);
And I'm getting:
System.AccessViolationException: Attempted to read or write protected memory.
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ugh! I should never have posted this.
In case anyone else looks to this thread for help, this solved my issue:
integer, value, intent(in) :: a, b

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page