- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everybody,
first time I address an issue I face in a forum. So, hopefully I have put together everything you need to better understand my problem.
Currently we are calling Fortran dlls from Java using FFI (in our case accordingly to the Panama Project).
Our Fortran test routine is very simple. With both IFORT and IFX this is working perfectly fine. The dll is compiling and Java can call the function.
subroutine get_greeting(out_string) bind(C, name = "get_greeting")
!DEC$ ATTRIBUTES DLLEXPORT:: get_greeting
implicit none
character(kind = c_char, len = 1), dimension(*) :: out_string
character(kind = c_char, len = 30) :: buffer_for_out
integer :: i
buffer_for_out = "Hello from Fortran"
do i = 1, len_trim(buffer_for_out)
out_string(i) = buffer_for_out(i:i)
end do
end subroutine get_greeting
Now I add one new line to my code with an allocatable like below to my Fortran program, the dll can be built with IFORT and IFX. So that is fine, too.
subroutine get_greeting(out_string) bind(C, name = "get_greeting")
!DEC$ ATTRIBUTES DLLEXPORT:: get_greeting
implicit none
character(kind = c_char, len = 1), dimension(*) :: out_string
character(kind = c_char, len = :), allocatable :: buffer2
character(kind = c_char, len = 30) :: buffer_for_out
integer :: i
buffer_for_out = "Hello from Fortran"
do i = 1, len_trim(buffer_for_out)
out_string(i) = buffer_for_out(i:i)
end do
end subroutine get_greeting
BUT now: when built with IFORT Java can call the dll as before and when built with IFX we are running into the issue
java.lang.IllegalArgumentException: Cannot open library: ....
So that was very weird for us. We have no idea why this one line now causes such an issue by only changing between the two compilers?
Any help would be much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems likely to me that by the introduction of an allocatable your DLL now depends on an extra runtime library. If that is not in the path, then the program that tries to load your DLL (or shared object) cannot succeed. Use a tool like ldd on Linux or dependency walker on Windows to find out which dynamic libraries are needed.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems likely to me that by the introduction of an allocatable your DLL now depends on an extra runtime library. If that is not in the path, then the program that tries to load your DLL (or shared object) cannot succeed. Use a tool like ldd on Linux or dependency walker on Windows to find out which dynamic libraries are needed.

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