- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am unable to run this little application:
!!!!!!!!! Program!!!!!!!!!!!!!!!!!
program fortranTest2
use dlltest
implicit none
REAL(8) :: n
call returnOne(n)
end program fortranTest2
!!!!!!!!! DLL !!!!!!!!!!!!!!!!!!!!!
subroutine returnOne(n)
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS :'returnOne' :: returnOne
REAL(8) , intent(out) :: n
n = 1.0
end subroutine returnOne
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
It tells me the following:
Error: Error in opening the Library module file. [DLLTEST]
What I tried:
**1**
I have added the dll directory in both
Libraries and Includes
by clicking on :
Tools->options->Intel Fortran
**2**
I have also tried to copy the dll in the
debug and ../debug directories.
**3**
And I have change the library type to see if it helped.
In Solution Explorer->DllTest ->Properties->Libraries
the library type is Single-Threaded
*************************************
Any suggestion on what i should do next ?
Thanks for your help.
I am unable to run this little application:
!!!!!!!!! Program!!!!!!!!!!!!!!!!!
program fortranTest2
use dlltest
implicit none
REAL(8) :: n
call returnOne(n)
end program fortranTest2
!!!!!!!!! DLL !!!!!!!!!!!!!!!!!!!!!
subroutine returnOne(n)
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS :'returnOne' :: returnOne
REAL(8) , intent(out) :: n
n = 1.0
end subroutine returnOne
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
It tells me the following:
Error: Error in opening the Library module file. [DLLTEST]
What I tried:
**1**
I have added the dll directory in both
Libraries and Includes
by clicking on :
Tools->options->Intel Fortran
**2**
I have also tried to copy the dll in the
debug and ../debug directories.
**3**
And I have change the library type to see if it helped.
In Solution Explorer->DllTest ->Properties->Libraries
the library type is Single-Threaded
*************************************
Any suggestion on what i should do next ?
Thanks for your help.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For the start, remove the "use dlltest" statement. It has nothing to do with the dlls whatsoever. Please Read the Fine Manual.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your comment, but it was not of great help to me.
Could you tell me what manual ? I looked at the fortran user's guide and was not able to find the answer to that question.
Thanks again.
Could you tell me what manual ? I looked at the fortran user's guide and was not able to find the answer to that question.
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, what happens if you remove USE DllTest statement? You certainly won't get the same error.
Look up USE and MODULE keywords in Language Reference chapter they're not related with dlls whatsoever.
To use a dll, at minimum you should link the .exe with dllname.lib and export the routines via !DEC$ATTRIBUTES DLLEXPORT or .def file.
However, since you use:
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS :'returnOne' :: returnOne
you have to provide an explicit interface for the dll, as it doesn't use the default calling conventions. So, you need an interface block, and you might define it in MODULE DllTest; instead of removing USE DllTest, write the module, in a separate .f90 file or before the PROGRAM, like this:
In this way, you will assure that the .exe "knows" how to call returnOne correctly.
Look up USE and MODULE keywords in Language Reference chapter they're not related with dlls whatsoever.
To use a dll, at minimum you should link the .exe with dllname.lib and export the routines via !DEC$ATTRIBUTES DLLEXPORT or .def file.
However, since you use:
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS :'returnOne' :: returnOne
you have to provide an explicit interface for the dll, as it doesn't use the default calling conventions. So, you need an interface block, and you might define it in MODULE DllTest; instead of removing USE DllTest, write the module, in a separate .f90 file or before the PROGRAM, like this:
MODULE DllTest
INTERFACE
subroutine returnOne(n)
!DEC$ ATTRIBUTES DLLIMPORT, STDCALL, REFERENCE, ALIAS :'returnOne' :: returnOne
REAL(8) , intent(out) :: n
end subroutine returnOne
END INTERFACE
END MODULE
In this way, you will assure that the .exe "knows" how to call returnOne correctly.

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